Exemplo n.º 1
0
def jfigtest():
    from jfig.utils import Array       # several array utilities
    from jfig.utils import MHG         # the plot functions
    m = MHG()                          # initalize the plot library,
                                       # reference via variab
    N = 200
    x = Array.linspace(0,10,N)         # 200 values (0.0 .. 10.0)
    y = Array.cos(x)                   # vector with cos(x)
    z = Array.random(N)                # 200 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' )               # red-dot markers
    m.xlabel( 'x' )                    # x-axis label
    m.ylabel( 'sin(x), random data' )  # y-axis label
    m.plotCartesianAxes()              # axes
    m.plotGrid()                       # grid
    m.doZoomFit()

    from java.io import File
    m.save( File( 'plot1.fig' ))       # save figure