Genstat for Windows Graphics

advertisement
Genstat for Windows Graphics
David Baird
AgResearch,
Lincoln.
April 2001
Contents
Creating Point and Line Plots ............................................................................................. 2
Single Y versus X Plot .................................................................................................... 2
Example 1................................................................................................................. 2
Editing the graph .......................................................................................................... 3
Editing the Axes ............................................................................................................ 5
Resizing the Graph ........................................................................................................ 5
Graphics Toolbars ......................................................................................................... 5
Printing the Graph ......................................................................................................... 6
Saving the Graph .......................................................................................................... 7
Inserting the Graph into Word ........................................................................................ 7
Resizing and Positioning the Graph in Word..................................................................... 8
Exercise 1 ................................................................................................................. 9
Multiple Y vs X Plots .......................................................................................................... 9
Grouped Data ............................................................................................................... 9
Multiple variates ............................................................................................................ 9
Example 2................................................................................................................. 9
Providing Text for the Key ........................................................................................... 10
Exercise 2 ............................................................................................................... 10
Exercise 3 ............................................................................................................... 10
Bar Graphs and Histograms ............................................................................................. 11
Example 3............................................................................................................... 12
Exercise 4 ............................................................................................................... 12
3-Dimensional and Contour Plots ..................................................................................... 13
Example 4............................................................................................................... 13
Exercise 5 ............................................................................................................... 13
GENSTAT GRAPHICS
David Baird
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.
Page 2
GENSTAT GRAPHICS
David Baird
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.
Page 3
GENSTAT GRAPHICS
David Baird
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 dropdown 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.
Page 4
GENSTAT GRAPHICS
David Baird
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).
Translation
Controls
Size
Control
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.
Page 5
GENSTAT GRAPHICS
David Baird
The vertical toolbar provides methods of manipulating the graph:
Select/pick
View
Help
Home
Set Home
View All
Seek
X Alignment
Y Alignment
Z Alignment
Projection

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.
Page 6
GENSTAT GRAPHICS
David Baird
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:
BMP Image
EMF Image
Page 7
GENSTAT GRAPHICS
David Baird
Title:
PlotMas ter
Title:
Creator:
PlotMas ter
Master Suite 3.5 TGS EUROPE a TGS Company
Creator:
Prev iew :
Master Suite 3.5 TGS
EUROPE a TGS Company
This EPS picture w as not s av ed
Prev iew :
w ith a preview inc luded in it.
This EPS picture w as
not s av ed
Comment:
w ith a preview inc luded
in it.picture w ill print to a
This EPS
Comment:
Pos tSc ript printer, but not to
This EPS picture w ill
printtyto
a of printers.
other
pes
Pos tSc ript printer, but not to
other ty pes of printers.
CGM Image
EPS Image
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.
Page 8
GENSTAT GRAPHICS
David Baird
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.
Page 9
GENSTAT GRAPHICS
David Baird
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,
and Rainfall versus Month.
The resulting graph should look similar to
that to the right.
Page 10
GENSTAT GRAPHICS
David Baird
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.
Page 11
GENSTAT GRAPHICS
David Baird
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:
PEN 2; COLOUR=4
DHISTOGRAM [ORIENTATION=vertical;TITLE='Mean Temperature by Month';\
BARCOVERING=0.9] mtable; PEN=2
Exercise 4


Open the file Open the file
P:\Gen542\G5Course\MinMax.GSH
Create a two-way bar chart of Temp by
Month and MinMax. (Note the view gets the
perspective of the graph wrong so click the
View All button to set this correctly).
Note: If you specify the order of groups
differently, you will obtain a different graph.
Page 12
GENSTAT GRAPHICS
David Baird
3-Dimensional and Contour Plots
There are a range of useful 3-dimensional graphs available in GenStat:



Contour, Shade and Surface plots take data on a two-way grid and display it
using colour and perspective for the surface plot.
A 3-dimensional scatter plot displays individual points in space.
A 3-dimensional histogram displays bars in perspective on up to two ways of
grouping.
The 3d-dimensional graphs can be rotated in space using the roll buttons or the hand
cursor.
Example 4




Open the GenStat spreadsheet file P:\Gen542\G5Course\Surface.GSH
Create a Contour plot of the values in Surface with 40 contours
Create a Shade plot of the values in Surface with 40 groups
Create a Surface plot of the values in Surface with 40 groups
You should obtain graphs that look similar to the following:
Exercise 5





Open the GenStat spreadsheet file
P:\Gen542\G5Course\PCPMeans.GSH
Create a 3-dimensional scatter plot of the variates
PC1, PC2 and PC3 as shown to the right and click
OK.
Add a title and axes titles for the X, Y and Z axis
and click Finish
Change the points to a larger more legible symbol
Rotate the points in space to examine their 3dimensional arrangement.
Page 13
Download