Chapter Contents |
Previous |
Next |
The GPLOT Procedure |
Requirements: | You cannot use the PLOT2 statement alone. It can be used only with a PLOT or BUBBLE statement. At least one plot request is required. |
Global statements: | AXIS, FOOTNOTE, LEGEND, PATTERN, SYMBOL, TITLE |
You can use statement options to manipulate the axes and modify the appearance of your graph. You can use SYMBOL definitions to modify plot symbols for the data points, join data points, draw regression lines, plot confidence limits, or specify other types of interpolation. For more information on the SYMBOL statement, see About SYMBOL Definitions.
In addition, you can use global statements
to modify
the axes; add titles, footnotes, and notes to the plot; or modify the legend
if one is generated by the plot. You can also use an Annotate data set to
enhance the plot.
PLOT2 plot-request(s) </option(s)>; |
option(s) can be one or more options from any or all of the following categories:
AREAS=n | |
GRID | |
LEGEND | LEGEND=LEGEND<1...99> | |
NOLEGEND | |
OVERLAY | |
REGEQN | |
SKIPMISS |
ANNOTATE=Annotate-data-set | |
CAXIS=axis-color | |
CFRAME=background-color | |
CTEXT=text-color | |
FRAME | NOFRAME | |
NOAXIS | NOAXES |
AUTOVREF | |
CVREF=reference-line-color | |
LVREF=line-type | |
VAXIS=value-list | AXIS<1...99> | |
VMINOR=n | |
VREF=value-list | |
VREVERSE | |
VZERO |
Required Arguments |
For more information about plot requests, see PLOT Statement.
In a PLOT2 plot request, the independent (X) variable for the horizontal axis must be the same as in the accompanying PLOT or BUBBLE statement. Typically, the dependent (Y) variable for the right vertical axis is different.
Use the same types of plot requests with a PLOT2 statement that you use with a PLOT statement, but a PLOT2 statement always plots the values of y-variable on the right vertical axis.
Options |
AUTOHREF | |
CHREF= | |
DESCRIPTION= | |
HAXIS= | |
HMINOR= | |
HREF= | |
HTML= | |
HTML_LEGEND= | |
HZERO= | |
LHREF= | |
NAME= |
See PLOT Statement for complete descriptions of options that you can use with the PLOT2 statement.
Matching Plot Requests |
The plot requests in both the PLOT and PLOT2 statements must be evenly matched as in this example:
plot y*x b*a; plot2 y2*x b2*a;
These statements produce two graphs, each with two vertical
axes. The first pair of plot requests (Y*X and Y2*X) produce one graph in
which X is plotted on the horizontal axis, Y is plotted on the left axis,
and Y2 is plotted on the right axis. The second pair of plot requests (B*A
and B2*A) produce another graph in which A is plotted on the horizontal axis,
B is plotted on the left axis, and B2 is plotted on the right axis.
Plot requests of the form (y-variable(s))*(x-variable(s)) in both the PLOT and PLOT2 statements generate multiple graphs. These statements produce graphs like the ones diagrammed in Diagram of Graphs Produced by Multiple Plot Requests in PLOT and PLOT2 Statements (the actual plots are produced on separate pages):
plot (y b)*(x a); plot2 (y2 b2)*(x a);
Diagram of Graphs Produced by Multiple Plot Requests in PLOT and PLOT2 Statements
When both the PLOT and PLOT2 statements use plot requests of the form y-variable*x-variable=third-variable, each statement generates a separate legend. If the third variable has two values, these statements produce one graph with four sets of data points, as shown in Diagram of Multiple Plots on One Graph (the figure assumes SYMBOL statements are used to specify the plot symbols that are shown and to connect the data points with straight lines):
plot y*x=z; plot2 y2*x=z;
Diagram of Multiple Plots on One Graph
Using a Second Vertical Axis |
For example, if Y is height in inches and Y2 is height in centimeters and if the Y axis values range from 0 to 84 inches and the Y2 axis values range from 0 to 213.36 centimeters, the plot will be like the diagram shown in Right Axis with Different Scale of Values.
Right Axis with Different Scale of Values
For plots
such as these, the PLOT2 statement should
use a SYMBOL statement that specifies INTERPOL=NONE and VALUE=NONE.
If your data contain variables with different data values (such as height and weight), you can display one type of data on the left axis and another type of data on the right axis. Because the Y variable and the Y2 variable contain different data, two sets of data points are displayed on the graph. For example, if Y is height and Y2 is weight, the plot will be like the diagram in Right Axis with Different Values and Different Scale.
Right Axis with Different Values and Different Scale
If your data contain two sets of values for the same type of data, you can use the PLOT2 statement to generate a right axis that is calibrated the same as the left axis so that the data points on the right of the graph are easier to read. For example, if Y is high temperatures and Y2 is low temperatures, you can create a graph like the diagram in Right Axis with Same Scale of Values.
Right Axis with Same Scale of Values
To scale both axes the same, specify the same range of values either with the VAXIS= option in both the PLOT and PLOT2 statements, or with AXIS statements.
Using PATTERN and SYMBOL Definitions |
For more information, see About SYMBOL Definitions.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.