from math import pi # standard Jython import from java.io import File # standard Java import from jfig.utils import Array # several array utilities from jfig.utils import MHG # the plot functions x = Array.linspace(0,8,500) # prepare some demo data y1 = Array.sin(x) y2 = Array.cos( Array.mult(x,5) ) s = Array.add( y1, Array.mult(y2,0.6)) m = MHG() # initalize the plot library m.figure(); # new plot window m.gca().setTrafo( -1.0, 9.0, -2, +2 ); m.xlabel( 'x' ) m.ylabel( 'sin(x) + 0.6*cos(5*x)' ) #m.title( 'simple function plot demo' ) #m.plot( x, s, "-b" ); #m.plot( Array.subset(x,0,490,10), # Array.subset(s,0,490,10), # "dr" ); m.title( 'stem plot' ) m.stem( x, s, 'color=red linewidth=2' ) m.gcf().setProperty( "AXIS_XLABEL_FORMAT", "%2.1f" ); m.gcf().setProperty( "AXIS_XTICKS", "0 2 5 8" ); m.gcf().setProperty( "AXIS_YLABEL_FORMAT", "%2.1f" ); m.plotGrid(); m.plotCartesianAxes() m.doZoomFit() m.save( File( 'demo2.fig' ))