8 HPlot class. The main canvas.

Assuming that you have run all the examples located in the directory ``macros/examples'', now one can learn more about the scripting. Click on JythonShell and type

>>> from jhplot import HPlot

This will import the main class to build a plot. Below we will discuss only Jython scripting. Analogously, you can write the programs in the BeanShell or JAVA.

>>> c1=HPlot("Canvas")

this will create a default canvas for plotting of the size 600x400 using the HPlot class.

To display it, execute the next statement:

>>> c1=visible(1)
which will display the canvas. Note: 1 means boolean "true", while 0 means "false". For BeanShell and JAVA, use "true" and "false" instead. If you do not want to show the canvas, use ``c1=visible(0)'' for Jython (or `` c1=visible(false)'' for BeanShell/Java.

There are more constructors for this class:

>>> c1=HPlot("Canvas",600,400)
creates a canvas of the size 600 by 400 pixels.

>>> c1=HPlot("Canvas", 600,400,0.2,1,2)
creates a canvas of the size of 600 by 400 pixels. The last two numbers indicates that 2 plots will be plotted (try also 2 and 2, 3 and 2 etc). One can navigate to the current plot using the ``cd()'' method. For example, if you want to plot a function or a histogram on the first plot, use:

>>> c1.cd(1,1)
>>> ..        # here goes some draw statement for first plot

If an object should be shown on the second graph, use

>>> c1.cd(1,2)
>>> ..        # here goes some draw statement for second plot

By default, the HPlot canvas has the range between 0 and 1 for the X and Y axis. You should specify the range using the method "setRange(X1,X2,Y1,Y2)". Alternatively, you can set autorange using the method "setAutoRange()".

Now, add some annotations. First, import Color from the awt and then set annotations:

>>> from java.awt import Color
>>> c1.setGTitle("Example of functions",Color.red) #put title
>>> c1.setNameX("X axis")
>>> c1.setNameY("Y axis")
>>> c1.setName("Canvas global title")
>>> c1.visible(1)                               # make it visible
>>> c.setAutoRange();  # set autorange

All the entries are self-explanatory. You may add some colors for the canvas by using:

>>> c1.setBackgroundColor(Color.yellow)

Also, specify the custom fonts for the legends as

>>> from java.awt import Font
>>> font=Font("Lucida Sans",Font.BOLD, 12)
>>> c1.setLegendFont(font)

You can further edit the global title by using the mouse. Read the documentation of JHPlot packagehttp://hepforge.cedar.ac.uk/jhepwork/api/jhplot/package-summary.html.