Subsections


3.2 Working with the HPlot canvas

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

3.2.0.1 Find USER or NDC coordinators

To determine the coordinate of the mouse in the USER coordinate system (i.e. determined by a range of X or Y axis) or the NDC (a user-independent, given by the actual size of the canvas on the screen) coordinate system, click the middle mouse button. The mouse should be located inside the area with the drawing.

3.2.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. Drag mouse holding the middle mouse button. A red line indicating a zoom region in X (or Y) will be shown. 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.

3.2.0.3 How to change titles, legends and labels

If one needs to change titles, legends and labels, select the appropriate object and double click on the right mouse button. A pop-up widow where all settings can be done well be activated. One can also change the location of a selected object by dragging it while holding the mouse button.

3.2.0.4 Edit style of data presentation

Use the right mouse button. In a pop-up menu select Edit. One should see a new frame window. By click on various buttons, one should be able:


3.2.0.5 How to modify the global margins

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. One will see a new pop-up menu. One can increase or decrease the divider location, make the divider invisible, change fonts and colors.

Exactly in the same way, the user can edit the left, right and bottom margins of the main frame. Just navigate to the frame boarder and use the mouse pop-up menu. One can access all attributes of the margins using the method:

>>> c1.panel()
This method returns the GHPanel class (an extension of the swing JPanel) which keeps attributes of all four margins. Here are several operations associated with this class:

>>> # 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 the jHplot API for more details.

3.2.1 Saving 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 other graphics attributes to be discussed below.

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 figures without running Jython macros. Look inside of this file after unziping it using Linux/UNIX prompt:

>>> unzip [file].jhp
This creates the directory with the name [file] with [file].xml (where [file] is the specified file name) and several data files. The general form of the names of the data files are: plotXY-dataZ.d, where X, Y are positions of a plot in HPlot canvas and Z indicates the data set number.

It should be noted that all data files are just the outputs from the P1D objects (see Sect. :autorefsection3.9). Therefore, one can easily read such files using the methods of the P1D class. This is useful in case if the automatic procedure from the File menu fails, and the user wants to re-plot the data using a different macro.


3.2.2 Cleaning canvas from graphics

All graphs on the same HPlot canvas can be removed by using several methods. If one needs to clear a graph from a loaded object (histogram, function etc.), use the method cleanData(). An example in the file histo_stream.py shows how to update a plot with new data every 0.5 sec.. Note: in this case only a current plot defined by the cd() method will be updated. If one needs 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 from a certain graph, as well as to remove input objects. In this case, the clear() method removes the current plot. One can also use clear(N1, N2), where N1 and N2 specify the plot locations. The method clearAll() removes all the plots, but keeps the main frame. The method close() removes the frame.


3.2.3 Axes

The axis range can be set automatically by calling setAutoRange() method.

>>> c1.setAutoRange()

The user can specify the range calling the method:

>>> c1.setRange(xMin,xMax,yMin,yMax)

One can remove all axes using:

>>> c1.removeAxes()

If only one axes should be drawn instead of all four, first remove all axes and then call the method:

>>> c1.setAxisY() # show only Y axis
>>> c1.setAxisX() # show only X axis

One can draw a small arrow at the end of axes as:

>>> c1.removeAxes()
>>> c1.setAxisX()
>>> c1.setAxisArrow(1) #  arrow type 1
>>> c1.setAxisArrow(2) #  another arrow type 2

If no mirror axis should be drawn, call

>>> c1.setAxisMirror(0,0) # no mirror axis on X
>>> c1.setAxisMirror(1,0) # no mirror axis on Y

If no tics should be drawn, call

>>> c1.setTicLabels(0,0) # no mirror axis on X
>>> c1.setTicLabels(1,0) # no mirror axis on Y

Call update() method to redraw the canvas. Look at a complete example in axes.py in the example directory.