#! /usr/bin/env python3 # def fly_plot ( ): #*****************************************************************************80 # ## fly_plot() draws a plot of two random flies in the unit circle. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 09 January 2022 # # Author: # # John Burkardt # import numpy as np print ( "fly_plot:" ) print ( " Plot two random flies in the unit circle." ) n = 100 theta = np.linspace ( 0, 2.0 * np.pi, n ) cx = np.cos ( theta ) cy = np.sin ( theta ) import matplotlib.pyplot as plt plt.plot ( cx, cy, 'b-', linewidth = 3 ) plt.grid ( True ) plt.axis ( 'equal' ) fx = 2.0 * np.random.rand ( 2 ) - 1.0 fy = 2.0 * np.random.rand ( 2 ) - 1.0 plt.plot ( fx, fy, 'g*', markersize = 10 ) plt.title ( 'Two random flies in a circle' ) filename = 'fly_plot.jpg' plt.savefig ( filename ) print ( " Graphics saved as '" + filename + "'" ) plt.show ( ) plt.close ( ) print ( "" ) print ( "fly_plot:" ) print ( " Normal end of execution." ) return if ( __name__ == "__main__" ): fly_plot ( )