from math import pi from jfig.utils import Array # several array utilities from jfig.utils import MHG # the plot functions m = MHG() # initalize the plot library, # reference via variable m N = 200 x = Array.linspace(0,10,N) # 100 values (0.0 .. 10.0) y = Array.cos(x) # vector with cos(x) z = Array.random(N) # 100 random values, range [0,1] z = Array.add( z, -0.3 ) # shift to range [-0.3, 0.7] m.figure(); # new plot window m.gca().autoscaleTight( x, y ) # default scaling m.plot( x, y, '-b' ) # solid blue line plot m.plot( x, z, '.r' ) # dotted line plot m.xlabel( 'x' ) m.ylabel( 'sin(x), random data' ) m.plotCartesianAxes() # axes m.plotGrid() # grid m.doZoomFit() from java.io import File m.save( File( 'plot1.fig' )) # save figure