The Second Wish - To Display Data
Examples of the use of many of these commands may be found in the gcl procedures in the /usr/local/genie/examples directory on ISIS UNIX systems or AXPLIB$DISK[OPENGENIE.GENIE.EXAMPLES] on ISIS VMS.
To plot data on a device, other than the main display window, you need to open a new device.
>>Device/open "device-type" width height
The default device is an X-window "XW". Other supported devices include "TEK4010" Tek 4010 compatible, "PS" postscript, "CPS" colour postscript, and "HPGL" HPGL driver for 7475A. For full details of the supported devices on each machine see the supported graphics devices in appendix B. The size of the page (in inches) is defined by the width and height parameters the default value is taken to be 8 inches. Alternatively you can open a device with a name:
>> device1 = Device:Open (type, width, height)
This is useful as Open GENIE supports multiple open devices, a given window can then be selected using the Select command. For example
>> Select Device1
Displaying a graphical plot of spectra from a workspace.
After the data has been read into a workspace from a RAW file or intermediate GENIE file, the data can then be plotted using the display command. The plot will be automatically scaled and titled with other relevant information from the workspace. For example:
# Display a spectrum but change the title first
>> wm = s(10)
>> wm.title = "This is my Nobel plot!"
>> display wm 0 100 -35 70
Alternatively you can plot it directly using
>> Display s(10)
which displays the 10th spectra of the default input file, or alternatively use the Get () command
>> Display get(10,"hrp00273.raw")
The parameters after the workspace wm are respectively xmin, xmax, ymin, ymax. All the parameters, except for the workspace, are optional and where omitted a default value will apply. Specifying a keyword for each parameter allows you to define each individual limit. For example, if the X limits should be defaulted, but the Y limits defined, then you could use:
>> Display wm ymin=-35 ymax=70
The parameters may also be expressions using functions of variables, for example
>> Display w1-noise 0 xmax/100.0 ymin = Min(w1.y) ymax = Max(w1.y)
Anonymous placeholders may also be used to indicate a default value - in Open GENIE the character _ is used. The above example could then be written as
>> Display w1 _ _ -35 70
>>
Other optional parameters that may be specified are:
Linecolour - the colour for drawing the axes and surrounding boxes,
Linewidth - the line width used for drawing line plots,
Textcolour - the colour used for drawing text.
Other qualifiers:
/HISTOGRAM - displays as a histogram assuming that the binned data has one more X value than Y value.
/LINE - displays a spectrum as if it is a numerically calculated function (i.e. with the same number of X-values as Y-values) and join the points with straight lines. Note: if histogram data is displayed with the /Line qualifier, the data will be transformed to take the bin centre positions as the X-values for the data points, this is done with the Centre_bins() function.
/MARKERS - displays a plot with markers symbols. For a list of marker types see appendix D.
/ERRORS - display as error bars taken from the workspace error array.
In order to clear the display surface on the currently open device:
>> Device/Clear
While
>> Device/Close
deactivates the currently open graphics device.
Performing a multiplot of 2-D spectra on the same x-axis
This is done using the Multiplot command, and it is useful for comparing groups of spectra from different detectors. A pseudo Y-axis is produced where successive plots are placed with an artificial Y offset value (ygap). Currently, multiplot only plots as a histogram. If used to plot a spectra from a raw file then the data source for the multiplot can be specified using the Set/File command. For example:
# Do multiplots from a file
>> multiplot 1:20 file = "mydata.raw" ygap=10.0
>> multiplot 1:300@3 # plot every third spectrum
Optional parameters (note the types) are: Linecolour (Colour), Linetype (LineStyle), Linewidth (Real), Textcolour (Colour1), Textheight (Real).
Overplotting an existing graph
This is done using the Plot command, which does not have the ability to create axes or scale the data. For example:
#Plot a vanadium spectrum on top of
#the data as a comparison
>> Display s(5) xmin=20000.0
>> Plot/Line get("vanadium1","normal.in3")
Qualifiers: /Histogram, /Line, /Markers, /Errors
Altering the graphics parameters in the Display(), Plot() and Multiplot() commands
Modifying characteristics of the plot is achieved using the commands Alter(), Toggle(), or Limits().
Alter/Status | Reports the values of all settings. |
Alter/Binning | Sets bin grouping for plotting. If the bin grouping value is set to a value greater than one, the display command groups the data by averaging the values of n-bin groups. It is possible to apply the same operation to a standard workspace permanently using the Groupbins() command. |
Alter/Device | Changes the interactive device. |
Alter/Font | Sets the text font for all the text used in the display. |
Alter/Hardcopy | Changes the default hardcopy device, when a Hardcopy() command is issued. |
Alter/Linecolour | Changes the axes and box colour |
Alter/Linetype | Changes the line style for line plots |
Alter/Linewidth | Changes the overall line thickness |
Alter/Markers | Sets the marker plot symbol |
Alter/Markersize | Changes the size of markers |
Alter/Plot | Changes the plot size |
Alter/Plotcolour | Changes the data plot colour |
Alter/Size | X window display size by a scale factor |
Alter/Textheight | Text height as the percentage height of the display |
Alter/Textcolour | Label and title colour |
For example:
# Change the axis colour to blue
>> Alter/linecolour $BLUE
For a list of supported graphics devices, supported colours, supported fonts, supported linestyles, and supported markers see appendix D.
The Toggle command can be used to amend plots, acting like an on/off switch for various settings. All the toggle commands switch the setting to its opposite value unless /Off or /On is specified.
Toggle/Status | Reports the values of all toggle settings. |
Toggle/Logx | X axis log/linear |
Toggle/Logy | Y axis log/linear |
Toggle/Clear | Screen clearing between plots |
Toggle/Graticule | Toggle graticule off/on |
Toggle/Header | Header plotted on Display() command. |
Toggle/RX | X axis rounding off/on |
Toggle/RY | Y axis rounding off/on |
Toggle/Info | Informational message printing on/off |
[/On] | Toggles item on |
[/Off] | Toggles item off |
For example:
# Switch off informational messages and display
# a data plot with no banner heading.
>> Toggle/info
>> Toggle/header
>> Display s(22)
The limits of the graph can be changed using the Limits() command. For example:
# Set the limits before doing a display
>> Limits/X xmin=10.0E4 xmax=50.0E4
>> Display # Redisplays previous plot with new limits
The command Limits/Default clears this. Note the actual setting of the limits will still be dependent on whether rounding is switched on for the X-axis.
Magnify a portion of the plot chosen interactively
This is done using the Zoom command, which redraws a plot scaling to a box which is selected by the cursor (the lower left-hand corner and the upper r.h corner of the box). The qualifiers /Errors, /Histogram, /Line, /Markers, will redraw the plot using error bars, histograms, lines, or markers respectively. While the /Multiplot qualifier expands a region of a multiplot. For example:
# Zoom in on the current plot
# and re-display with error bars
>> zoom/errors
Plotting data from an ASCII file
In this example the data used is prs_001.obs, which can be found in the directory of "../genie/examples/prisma". To construct a plot if you have read in a non Open GENIE type file, e.g. an ASCII "X,Y,E" file into w.x, w.y, w.e, then after clearing the current graphics device using
>> Device/Clear
a window must be created with the Win_ commands. In this case a Scaled or AutoScaled window is created by
>> Win_Scaled 0.1 0.9 0.1 0.9 0.975 7.475 0.02 0.17
The first four numbers define the device co-ordinates - the position of the plotting box on the page, and the last four numbers are the global co-ordinates - the X and Y range of the plot. The points of the graphical device range from 0.0 and 1.0. By using the Win_Autoscale command, and quoting the x and y arrays in the parameter list the range of the plot are chosen automatically; for example:
>> Win_Autoscaled 0.1 0.9 0.1 0.9 w.x w.y w.e $Red
where w is the workspace containing the data, and the $red parameter will paint the chosen window red instead of the default black.
Now we can create the graph
>> Graph/Draw w.x w.y
green axes can be drawn by
>> Axes/draw colour=$green
By default the axes are linear, and the x and y axes are labelled horizontally and vertically respectively. To display x/y labels on the graphics device
>> Labels/draw "X Axis" "Y Axis"
To draw text on the graphics device
>> Text/draw 0.0 1.0 "some text" colour=$yellow size=3.0 angle=45.0 font=$script
the position is specified in world co-ordinates.
To display a title on the graphics device
>> Title/draw "A Title"
Comparing this data with the data from the file prs_001_lmf.cor (after loading the ASCII data file into the w1.x, w1.y and w1.e) plot the data with markers as blue crosses
>> Markers/draw w1.x w1.y $Blue $Cross 2
To include Y error-bars
>> Errors/draw/Vertical w.x w.y w.e $Blue 2
and to draw a green graticule on the window
>> Graticule/draw colour=$green
Note: for a complete list of qualifiers associated with these commands see the Open GENIE reference manual.
To ensure the above picture and its associated objects can be referred to later, after a new picture has been created then initially a picture should be created,
>> Picture1=Picture()
and then the following commands used
>> Scaled1=Win_Scaled(0.1,0.9,0.1,0.9,0.975,7.475,0.02,0.17)
>> Graph1=GRAPH:DRAW(w.x, w.y)
>> Axes1=axes:draw(colour=$green)
>> Labels1=labels:draw("X Axis", "Y Axis")
>> Text1=text:draw(0.0, 1.0, "some text", colour = $yellow size=3.0, angle=45, font = $script)
>> Title1=title:draw("A Title")
>> Markers1=markers:draw(w1.x,w1.y,$Blue,$Cross,2)
>> Errors1=errors:draw:Vertical(w.x, w.y, w.e $Blue 2)
>> Graticule1=graticule:draw(colour=$green)
If you wish now to change part of the graphs for example the text in picture1
# Want the font to be italic
>> Title/alter font=$italic object=title1
or you want to change the graticule
>> Graticule/alter colour=$red object=graticule1
In order to remove the changes caused by the /draw qualifier the Undraw command can be used. For example, if you wanted to undraw markers1 then type
>> Undraw markers1
Note: if the Undraw command is followed by a negative integer, N then it is the previous Nth Draw that is undone. In other words, Undraw -1, undoes the previous Draw command (the default); whereas Undraw -3 undoes the command two before the last one.
For a whole set of pictures and opened devices made for example picture1, picture2 picture3 picture4 etc. and device1, device2, device3, device4, etc., then to redraw picture4 on device5, and picture 6 on device2 then type
>> Redraw picture4 device5
>> Redraw picture6 device2
In order to redraw a previous plot then type
>> Redraw -1
After a number of Device:Open() commands have been executed then to redraw the current picture on the current device type
>> Redraw 0.
Display a cursor on the graphics screen to allow annotation
This is done using the Cursor command. An obvious use is for tagging peaks with the data value in the X or Y direction at the point selected by the cursor. For example
# Display a cursor near the expected position
# of a peak in world co-ordinates.
>> Cursor/Horizontal 10000.0 50.0
# If /vertical is used instead then the text is drawn vertically
a cursor is displayed and waits for a pressed key, if X - displays "X co-ordinate"; Y - displays "Y co-ordinate"; P - displays both co-ordinates; T- to add text; and E-exit. See also the GetCursor command in the Open GENIE reference manual.
To save a hardcopy of the graphics into a file
The Hardcopy command allows a copy to be made of either the currently displayed window, or an earlier picture to a postscript file. For example:
# Save a copy of the last but one picture as
# colour postscript (found with Redraw/Info)
>> Hardcopy filename = "test.cps" picture = my_pict
The default name of the file into which the hardcopy is placed is "GENIE.PS". The filename extension is one of the supported hardcopy graphics devices. For full details of supported devices on each machine type see the appendix. The default picture selected is 0 - the last picture created. Normally just typing Hardcopy is sufficient to make a hardcopy of the current screen.
A whole series of graphics commands can be strung together and stored as a procedure. See for example the various directories of /usr/local/genie/examples. The procedures are then loaded using the command
>> Load "File.gcl"
and executed using the command
>> File