GenStat GraphicsDavid Baird

Genstat for Windows Graphics

David Baird

AgResearch, Lincoln.

April 2001

Contents

Creating Point and Line Plots

Single Y versus X Plot

Example 1......

Editing the graph

Editing the Axes

Resizing the Graph

Graphics Toolbars

Printing the Graph

Saving the Graph

Inserting the Graph into Word

Resizing and Positioning the Graph in Word

Exercise 1......

Multiple Y vs X Plots

Grouped Data

Multiple variates

Example 2......

Providing Text for the Key

Exercise 2......

Exercise 3......

Bar Graphs and Histograms

Example 3......

Exercise 4......

3-Dimensional and Contour Plots

Example 4......

Exercise 5......

Creating Point and Line Plots

Single Y versus X Plot

The graphics menu allows you to either choose a graph type from a selection of graph types using the Graphics>Create Graph menu or if you know the type, by using a specific Graphics menu (Point plot, Line Plot etc).

If you use the Graphics Wizard, Select the graph type from the list and press the next button to specify the data for the graph.

Example 1

  • Open the Genstat spreadsheet P:\Gen542\G5Course\Fasting.GSH.
  • Open the Graphics>Point plot menu.
  • Select Type of Plot as Single XY.
  • Select the variate LiveWt from the drop-down list for the Y values.
  • Select the variate Time from the drop-down list for the X values.
  • Click the Next button
  • Enter the title “Live weight vs Time” for the graph.
  • Click the X Axis tab.
  • Enter a X axis title "Time (days)" and enter any other options for the axis.
  • Click the Y Axis tab.
  • Enter a Y-axis title "Live weight (kg)" and enter any other options for the axis.
  • Click the Finish button to create the graph.

A graph like that to the right should appear in the Genstat Graphics window.

Editing the graph

The graph created in the Graphics Window can be edited using the Graphics editors found under the Tools menu.

The Title and key can be edited with the Tools>Graph editor menu which brings up the window to the right. This can be used to edit the text in the title, the font for the title and whether a key is displayed for the graph.

If you click the Title Font button, you can change the font using the Font dialog. The dialog to the right shows the font being set to 20-point size. The colour of the font can also be chosen.

The symbols and lines used for plotting the data series can be changed using the Tools>Data editor. The data series to be changed can be selected from the drop-down list. The type of lines used to connect the points up are specified with the Line Styles entries, and the symbols plotted at each plot with the Symbols entries.

The choice of line style methods is:

  • None - no lines between points
  • Line - Straight lines between points
  • Monotonic - Smooth curves between points in order of increasing X values.
  • Open - Smooth curves between points in order of values in series.
  • Closed - Smooth curves between points, joining up the final and first point.

The Open and Closed options are not normally useful for 2-d plots.

There are a choice of colours can be made from a set of standard colours or from the complete windows colour palette using the Other button. This opens the Colour Palette shown below right.

To select a colour from the Colour Palette you must use the following steps:

  • Click on either a basic colour and Click OK.
  • Or click on the colour in the spectrum that you want to use (shown by the hollow cross).
  • Select the intensity from the slider on the right hand side (shown by the small triangle).
  • Click the Add to Custom colours button.
  • Click on the new custom colour and click OK.

There are 25 symbol types. The symbols before the “User” symbol are two-dimensional and may be have the outlines drawn in one colour and be filled with a separate colour. The types after “User” (Sphere, Cone, …) are three-dimensional shaded symbols and do not use the specified fill colour.

You must click the Apply button before moving on to change the properties of another data series.

Editing the Axes

The axes can be edited by using the Tools>Axis editor menu. This opens a dialog shown to the right, with a tab for each axis in the graph. The Axis title and labels can be changed using this editor, as can the fonts for the title, labels, and the colour and thickness of the line. The layout of the ticks and a grid can also be set with this dialog.

Resizing the Graph

The translate (Trans X, Trans Y), Zoom and Dolly controls can be used to resize the image within the graphics window. The translate rollers move the graph left and right (Trans X) or up and down (Trans Y). The Zoom roller enlarges/shrinks the graph about its home point. To move a roller, click down on the roller button and drag your move left/right or up/down as appropriate.

For a 3-dimensional graph, the two Trans rollers are renamed to Rotx (rotates the graph in X direction) and Roty (rotates the graph in Y direction).

Graphics Toolbars

There are two graphics toolbars that can be displayed (the option to show or hide these are the Options>Graphics toolbar for the vertical toolbar and View>Toolbar for the horizontal toolbar.

The horizontal toolbar provides short cut icons to menu items: Open GMF file, Save, Print, Copy, Previous & Next Window and Help respectively.

The vertical toolbar provides methods of manipulating the graph:

  • Select/Pick Button - selects object manipulation or pick mode (and deselects camera or viewer mode). The cursor shape will change to an arrow. In this mode, the user is manipulating objects in the scene graph.
  • View Button - selects camera or viewer mode (and deselects object manipulation or pick mode). The cursor shape will change to a hand icon. In this mode, the user is moving the camera in 3D space.
  • Help Button - this menu provides help about the application.
  • Home Button - returns the camera to its home position (initial position if not reset).
  • Set Home Button - resets the home position to the current camera position.
  • View All Button - brings the entire scene graph into view.
  • Seek Button - allows the user to select a new centre of rotation for the camera. When clicked on (and in viewer mode) the cursor changes to a crosshair. The next left mouse button press causes whatever is underneath the cursor to be selected as the new centre of rotation. Once the button is released, the camera either jumps or animates to its new position depending on the current setting of the seek time in the preferences dialog box.
  • Camera Alignment Buttons - select the axis of alignment (X, Y, or Z) of the camera. This is only displayed for plane viewers.
  • Projection Button - selects the type of camera used by the viewer. It toggles between the two available camera types - perspective and orthographic.

Printing the Graph

To print the graph, use the File>Print or the File>Print Preview menu items. At present, the size of the graphics window affects the size that the graph prints on the page. Results that are more reliable are obtained by saving the graph as an EMF file and then inserting it into Word and then printing it from Word.

Saving the Graph

The graph can be either saved in the native Genstat format (GMF) or in either a device independent format (EMF - Enhanced Metafile) or in standard graphics formats (BMP, EPS, CGM etc).

The GMF format has the advantage that you can open the graph again in the GenStat graphics and edit it further.

The EMF format will print with full precision, and can be inserted into Word. The inserted image can be resized within Word and display on the screen.

To save the graph as a GMF file, just click the Save button and provide a file name.

To save as one of the other types, use the File>Save As menu, and then select the type from the Files of Type drop down list as shown to the right.

Inserting the Graph into Word

To insert saved image into word (EMF, BMP, CGM or EPS), use the Insert>Picture>from File menu in Word and select the image you want to insert. The image will be positioned in Word at the cursor position when you gave the Insert command. The EPS file format will not display in Word and will just be displayed as a blank box, but will print out correctly. Here are the 4 different formats inserted into this document:

Resizing and Positioning the Graph in Word

To move the image around in Word you will need to change the Picture Layout. To do this double click the picture, or select the picture by clicking it once so that its border is highlighted (showing small boxes on the frame) and then use the Format>Picture menu. This will open the Format Picture dialog shown to the right. To position the picture where you want, select the Layout tab and choose a Wrapping style: options Square or Tight will flow the text around the picture, and Behind or In Front require you to create blank space to insert the picture in.

At present GenStat tends to allow too large a margin around a picture, and the margins can be trimmed back by specifying that the image be cropped on the Picture Tab.

The image can then be dragged to anywhere in the text, and resized by selecting the picture and clicking on one of the corner boxes and dragging inwards to reduce the size, or outwards to increase it.

Alternatively you could click on the picture and use the crop tool from the picture toolbar (shown to the right) and drag the margins in by clicking on the selection markers on the sides of the picture and dragging then inwards.

Exercise 1

  • Open the GenStat spreadsheet file P:\Gen542\G5Course\Cauli.GSH.
  • Do a point plot of the number of Florets versus Temperature.
  • Use the graph editor to enhance the default plot and save it for insertion into Word.
  • Open Word and insert the saved graph and resize it to quarter page size.
  • Print the graph.

Multiple Y vs X Plots

There are two ways of producing multiple series of data points on a single graph – a single Y and X variate with a factor that defines groups of points to be plotted together, or multiple Y variates (with a common or separate X variates). These options are available on the standard Point or Line Plot menu’s.

Grouped Data

For grouped data, the factor name is provided in the last drop down list as shown to the right.

Multiple variates

For multiple variates, the Type of Plot drop down list is used to select a type: Multiple X ( with common Y), Multiple Y ( with common X), or Paired XY (one Y or each X). Then you must choose sets of variates from the Y and X lists. Each selection will create another entry in the lists that can have multiple entries. You may also have a grouping factor for each Y variate.

Example 2

Using the data in P:\Gen542\G5Course\Cauli.GSH, a grouping factor Year is added to the graph, as shown to the right.

After some editing within the graphics editor, the final graph as on right is produced.

Providing Text for the Key

The default labelling of the key in grouped plots is presently uninformative with repeated labels of Y vs X being produced. The menu system cannot presently be used to provide better text in the key. The only way to provide this text is through editing the graphics commands produced by the menu and re-running the new commands. These commands can be found in the Input Log window. After producing the graph in Example 2, the DGRAPH directive in the input window is:

DGRAPH [TITLE='Cauliflower Florets vs Temperature'] Y=Florets; \

X=Temp; PEN=NEWLEVELS(Year;!(1..._nlevs))

To this command the parameter DESCRIPTION=list of labels can be added. The labels have single quotes, separated by commas and are grouped with a !T(). The extra parameter is separated from the previous parameters by a semi-colon. Adding on the names of two years to the above directive we would get:

DGRAPH [TITLE='Cauliflower Florets vs Temperature'] Y=Florets; X=Temp; PEN=NEWLEVELS(Year;!(1..._nlevs)); \ DESCRIPTION=!T('1957','1958')

Select the all directives from the XAXIS directive down to the end of the input windows and re-run this with the Run>Submit Selection menu item. The graph will be recreated with a more useful key.

Exercise 2

  • Open the GenStat spreadsheet file P:\Gen542\Course\Examples\ATP.GSH
  • Do a graph of ATP versus time with heart for groups.
  • Provide labels '1', '2', … for the key and recreate the graph with these.

Exercise 3

  • Open the GenStat spreadsheet file P:\Gen542\G5Course\Weather.GSH
  • Do a Multiple Y Line plot of MinTemp,MeanTemp,MaxTemp, andRainfall versus Month.

The resulting graph should look similar to that to the right.

Bar Graphs and Histograms

The Graphics>Histogram menu can be used to create a histogram of a variate, where the counts within a set of data ranges (bins or groups) is displayed. After the variate to be counted is chosen, the Options dialog allows you to specify the ranges of the groups to be used. The dialog to the right shows a selection of a given number of groups, which will be calculated from the data to cover equal size ranges from the minimum to the maximum of the data. Other options are a set bin width, specified limits or the unique data values in the variate. The bins can be restricted to just occur between an upper and lower limit.

The resulting histogram is displayed to the right. When using the data editor in the graphics program, only the colour of the bars may be changed as shown below.

A bar chart can be produced from a Table of means or counts. The Bar Chart graph type is not on the main Graphics menu and must be selected through the Graphics>Create Graph menu shown to the right. Tables are normally produced using the Stats>Summary Stats> Summary by Groups menu. The table can be created using the Create Table button on the Bar Graph dialog. You are then given the choice of creating a table by typing in the values or constructing a table through summarizing a variate by groups. If you choose the groups option you will need to specify the factors to group by, the variate to summarize and what sort of summary to make (counts, means etc) as shown to the right.

Example 3

  • Open the file P:\Gen542\G5Course\MinMax.GSH
  • Select the Graphics>Create Graph menu item
  • Select a Bar chart & click next.
  • Click the Create Table button and select the Groups option & click OK
  • Choose Months for the Groups field, Temp for the summary variate and the Means option (as shown in the dialog at the bottom of the previous page)
  • Set the name for the table (say mtable) and click OK to create the table.
  • You will be return to the Bar chart dialog with the table name filled in from your choice on the previous dialog. Click next to move on to the Bar chart options
  • Give the graph a title and choose the orientation for the bars.
  • On the axis tab select any options you want for the axis and name it and then click finish.
  • A graph like that to the right will be created, but with the multi-colour bars.

You cannot change the colours of the bars in the graph editor. To change these you will need to alter the directives in the input log and re-run them. The DHISTOGRAM directive has a PEN parameter that lets you specify a single pen or a set of pens to draw the bars. To use this you need to assign the colour you want to a pen (or 12 pens - one for each bar for separate bar colours) and specify this pen on the DHISTOGRAM directive as shown below: