""" From "A SURVEY OF COMPUTATIONAL PHYSICS", Python eBook Version by RH Landau, MJ Paez, and CC Bordeianu Copyright Princeton University Press, Princeton, 2012; Book Copyright R Landau, Oregon State Unv, MJ Paez, Univ Antioquia, C Bordeianu, Univ Bucharest, 2012. Support by National Science Foundation , Oregon State Univ, Microsoft Corp""" # EasyMatplot.py: Simple use of matplotlib's plot command from pylab import * # Load matplotlib Xmin = -5.0; Xmax = +5.0; Npoints= 500 DelX= (Xmax-Xmin)/Npoints # Delta x x = arange(Xmin, Xmax, DelX) # x range + increment y = sin(x)*sin(x*x) # Function to plot print 'arange => x[0], x[1],x[499]=%8.2f %8.2f %8.2f' %(x[0],x[1],x[499]) print 'arange => y[0], y[1],y[499]=%8.2f %8.2f %8.2f' %(y[0],y[1],y[499]) print "\n Now doing the plotting thing, look for Figure 1 on desktop" xlabel('x'); ylabel('f(x)'); title(' f(x) vs x') # labels text(-1.5, 0.1, 'MatPlotLib Example') # Text on plot plot(x, y, '-', lw=2) grid(True) # Form grid show() # Make screen plot