Subsections


9 Working with the HPlot canvas

There are few important operations you should know when working with the HPlot canvas frame:

9.0.1 Find the USER or NDC coordinators

To determine the coordinate of the mouse in the USER coordinate system or the NDC (user-independent) coordinate system, click the middle mouse button. The mouse should be located inside the area with a drawing.

9.0.2 Zoom in to a certain region

To zoom in, use the middle mouse button. The mouse location should be below the X-axis or on the left of Y-axis. Then drag the mouse. You will see a red line indicating a zoom region in X (or Y). After releasing the middle mouse button, you will see an updated HPlot canvas with a new axis range. To set the axis range to the default, use the right mouse button and select a pop-up menu "Default axis range".

9.0.3 Change titles, legends and labels

If you want to change titles, legends and labels, select and double click with the right mouse button. You will see a pop-up widow where all settings can be done. You can also change their location by dragging them.

9.0.4 Edit style of data presentation

Use the right mouse button. In a pop-up menu select "Edit". You will see a new window. By click on various buttons, you should be able:


9.0.5 How to global margins with the mouse

To change the global title (which is set with the setGTitle() method), navigate the mouse to the location of the global title (the very top of the frame) , and click on the right mouse button. You will see a new pop-up menu. You can increase or decrease the divider location, make the divider invisible, change fonts and colors.

Exactly in the same way, you can edit the left, right and the bottom margins of the main frame. Just navigate to the boarder and use the mouse pop-up menu.

You can access all attributes of the margins using the method:

>>> c1.panel()

This method returns the GHPanel class (an extention of the swing JPanel) which keeps attributes of all 4 margins. Here are several operations you can do with the global margins:

# set size of the global margins (in pixels)
>>> c1.setMarginSizeLeft(50)
>>> c1.setMarginSizeRight(20)
>>> c1.setMarginSizeBottom(50)
>>> c1.setMarginSizeTop(50)

# get the margin size
>>> a=c1.getMarginSizeLeft()
>>> a=c1.getMarginSizeRight()
>>> a=c1.getMarginSizeBottom()
>>> a=c1.getMarginSizeTop()

# set text of the global margins
>>> c1.setTextBottom("This is X")
>>> c1.setTextLeft("This is Y")
>>> c1.setTextTop("This is X") # the same as setGTitle() 
>>> c1.setTextBottom("This is Y")


# set global margin background
>>> c1.setMarginBackground(Color color) 


# returns JPanel of the global margins
>>> c1.getMarginPanelLeft()
>>> c1.getMarginPanelRight()
>>> c1.getMarginPanelTop()
>>> c1.getMarginPanelBottom()

Look at jHplot API for more details.

9.1 Saving HPlot plots in XML files

One can save HPlot figures in external files using the "File" menu. Of course, plots can be restored using the same menu. This works for most of the plotted objects, like HLabel, Primitives and graphics attributes.

This is about the file format: The output files have the extension "*.jhp" and contain an XML file which keeps all attributes of the HPlot canvas and the data files necessary to recreate the figures. You can look inside of this file just by unziping it using the Linux/Unix prompt:

>>> unzip <file>.jhp

This will create a directory <file> with <file>.xml and several data files. The general form of the names of the data files are: "plotXY-dataZ.d", where X, Y are positions of the plot in HPlot canvas and Z indicates the dataset number.

It should be noted that all data files are just the outputs from the P1D object (see Sect. :autorefsection13). Therefore, you can easily read such files using methods of the P1D class. This is useful in case if the automatic procedure from the "File" menu fails, and the user want just re-plot the data using different macros.


9.2 Cleaning plots from data

All graphs on the same HPlot canvas can be removed by using a several methods. If you want to clean a graph from a loaded object (histogram, function etc.), use the method ``cleanData()''. An example in the file ``macros/example/histo_stream.py'' shows how to update a plot with new data every 0.5 sec.. Note: in this case only a current plot will be updated, i.e. a plot given by the ``cd'' method. If you want to remove all objects from all plots on the same HPlot canvas, use ``cleanAllData()''.

It is also useful in many cases to remove all user settings for a specific graph, as well as to remove input objects. In this case use the ``clean()'' method. This will clean the current graph from the data and from user settings. The method ``cleanAll()'' will clean all the graphs on the same canvas.