5. Plot view

The plot view is the main window where all graphical plotting is displayed. A plot view is a generic plotting UI, that allows graphical plotting of different scalar dataset types. Currently supported scalar plots are:

  • multiple 1D scalar
../../_images/plot1d.png
  • multiple 1D scalar as a series in 3D
../../_images/plot1d_3d.png
  • 2D scalar as image
../../_images/plot2d.png
  • 2D scalar as 3D surface plot
../../_images/plot2d_surf.png

It is possible to have more than one plot view open and plot to them simultaneously and usually they are named Plot 1, Plot 2, ..., Plot n. The name is important since it is used to send data to via the Jython terminal.

Plotting any data in any form to one of the plot views can be done using the plotting package:

  • 1D scalar plots:

    import scisoftpy.plot as dpl
    
    dpl.plot([xAxis,] yAxes)

    plots the given yAxes dataset (or list of datasets) against a xAxis dataset (if given)

  • multiple 1D scalar plots as 3D series:

    dpl.stack([xAxes,] yAxes, zAxis=None)

    plots all of the given 1D yAxes datasets against corresponding xAxes (if given) as a 3D stack with specified z coordinates

  • 2D scalar image plots:

    dpl.image(image, xAxis=None, yAxis=None)
    

    plots the 2D dataset as an image

  • 2D scalar 3D surface plots:

    dpl.surface(data, xAxis=None, yAxis=None)
    

    plots the 2D dataset as a surface

By default, these functions sent data to Plot 1. This default can be changed using:

dpl.setdefname('Plot 2')

Otherwise, data can be sent to other plot views on a plot-by-plot basis using the optional keyword argument, name. For example:

dpl.plot(yAxis, name="Plot 2")

Both 2D image plots and 2D surface plots will open automatically a histogram view panel that is associated to the plot view. Through the histogram view it is possible to control the mapping of the data values in the plotted image or surface to the different colours.

../../_images/histogram.png

5.1. 2D Image Plot Profiles

The plot profile tools inhabit a side plot panel. The tools are activated by clicking on the toolbar buttons in the plot view. These buttons become visible when an image is plotted.

The coordinate system used in the image plot is in pixels starting from the upper left at (0,0) with x increasing when moving left and y increasing moving down. Angles are measured from the horizontal and increases when moving clockwise.

There are three profile tools: line, box and sector tools. Each allows the selection of multiple regions of interest (ROIs). The purpose of the ROIs is to allow profiles of the image within a ROI to be plotted. These plots reside in the top part of the panel.

../../_images/lprof01.png

Line profile tool

When a profile tool is active, a region of interest can be specified using the mouse to click and drag out a ROI. The ROI is shown as an overlay on the image. Once done, the ROI can be further manipulated with use of its handle areas. The brightness of the ROI outline can be inverted using the “Invert brightness” checkbox to improve its contrast with the image.

The handle areas operate in two ways: a left click on an area enables that area, and the part of the ROI to which it is attached, to be moved; a right click (or alternatively, simultaneous holding a shift key and left clicking) cause some type of rotation to occur. Generally, a central handle area allows translation of the ROI or rotation about that handle area. A handle area at a vertex will allow resize of the ROI (leaving the opposing vertex fixed) or rotate about the opposite vertex.

Once a profile is plotted, it can be added to a store using a toolbar button above the plotting area. The oldest item in the store also can be removed using a toolbar button. There are separate stores for each type of profile.

Each linear ROI can have an optional cross, linear ROI defined to form a cross-hair. This cross ROI is a perpendicular bisector of the same length as its partner. The line profile is plotted in the graph and dashed lines are used for cross ROIs.

../../_images/bprof01.png

Box profile tool

A rectangular ROI defined in the box profile tool is defined by its starting point, width (major axis length), height (minor axis length) and orientation angle of its major axis. The upper graph shows the integration values over the minor axis as the position on the major axis is varied. The lower graph shows the converse. There is a “clipping comp” checkbox available that attempts to compensate for the situation where a ROI lies partially outside the image, i.e. the ROI is clipped by the boundaries of the image. In this case, some of the integration values are subdued by the lack of pixels (they are represented by zeros in the ROI) outside the image and the compensation scheme boosts those values by the ratio of the full integration length to the clipped length. Note that this compensation can introduce extrapolation errors and is prone to erroneous results where the clipped length is short and when the pixel values are noisy.

The sector ROI is distinguished by the necessity of defining a centre point. Once defined, the sector ROI operates in a manner dictated by a polar coordinate system (radius r, angle phi) so rotation operations on the handle areas act like translations in polar coordinates. Also, the angular symmetry can be selected for a sector ROI that can alter the ROI or make a copy subject selected symmetry:

None
No symmetry
Full
360 degrees
L/R reflect
Left/right reflection
U/D reflect
Up/down reflection
+90
Rotate 90 degrees clockwise
-90
Rotate 90 degrees anti-clockwise
Invert
Invert through centre

The upper graph shows the azimuthal integration as the radius is varied and the lower graph shows the radial integration as the azimuth angle is changed. Ticking the “combine symmetry” checkbox allows any separate symmetry-selected ROI to be combined in the profile plots, otherwise the separate ROI is plotted as dashed lines.

The current ROI can also be modified using the spinner widgets that are displayed in the centre part of the side plot panel. Each spinner is editable and can alter a parameter of the ROI. Once the ROI has been defined, it can be saved and then displayed in the table at the bottom of the panel.

../../_images/sprof01.png

Sector profile tool

Multiple ROIs can have their profiles plotted by clicking on the checkboxes in the table. Any ROI in the table can be selected and replace the current ROI, copied in place of the current ROI or deleted using a right mouse click anywhere on the row of the ROI.

5.2. Plot GUI information

GUI information from interactions with the plot view and side panels can be passed back and forth from the view to the Jython console.

The plot client regularly updates the console with GUI information. This can be obtained using the plotting package:

import scisoftpy.plot as dpl

# grab a GUI bean
gb = dpl.getbean()

By default, this function returns information from Plot 1 - use the keyword argument name to obtain information from other named plot views. Again, the default view name can be changed with dpl.setdefname. The GUI bean is a dictionary object with a set of possible keys listed in the GUI parameters class. None is returned if there is no dictionary present. You can add in new entries or overwrite existing ones. Modified GUI beans can be pushed back to a plot view:

dpl.setbean(gb)

and the view will respond appropriately to the updated GUI information. The keys for the dictionary are listed as strings in the GUI parameters class:

dir(dpl.parameters)

5.3. ROI objects

The regions of interest defined are in the ROI package:

import scisoftpy.roi as droi

These are

line
A line segment defined by its starting point, length and angle
rect
A rectangle defined by its starting point, width, height and angle
sect
A sector defined by its centre point, bounds on radius and azimuthal angle

As mentioned in the previous section, the current ROI and any ROIs stored in the table are sent via a GUI bean back to the plot view.

The current ROI is held in the GUI bean under the key parameters.roi and the table of ROIs under the key parameters.roilist. The values held under those keys depend on which side panel is active.

When the line profile tool is being used, the parameters.roi item is a linear ROI object and any stored ROIs are held in a Jython list of linear ROIs:

cr = gb[dpl.parameters.roi]

# or use convenience function
cr = dpl.getroi(gb)

# print current ROI's starting point, length and angle (in radians)
print cr.point, cr.length, cr.angle

lr = gb[dpl.parameters.roilist]

# or use convenience function
lr = dpl.getrois(gb)

# get first item
ra = lr[0]

print ra.length, ra.angleDegrees

# copy ROI from list
roi = gb[dpl.parameters.roilist][0].copy()

# or use convenience function
roi = dpl.getrois(gb)[0].copy()

# modify ROI
roi.setPoint(100,50)

# import region of interest package
import scisoftpy.roi as droi
list = droi.linelist()
list.add(roi)
gb[dpl.parameters.roilist] = list

# or use convenience function
dpl.setrois(gb, list)

# push bean back
dpl.setbean(gb)

The ROIs obtained from the client can be used with image datasets to calculate profile datasets in the console:

# for a linear ROI lroi, image dataset and a step size of 0.5 pixels,
# lprof is a list of datasets. The first element is the profile along the
# line and the second element is along the perpendicular bisector (if the
# crosshair option is set)
lprof = droi.profile(image, lroi, step=0.5)

Table Of Contents

Previous topic

4. File Input/Output

Next topic

6. NeXus Tree View

This Page