Chapter Contents |
Previous |
Next |
The G3D Procedure |
Requirements: | Exactly one plot request is required. |
Global statements: | FOOTNOTE, TITLE |
Alias: | SCAT |
You can use statement options to modify any of the three plot axes as well as the general appearance of the graph, control the viewing angle, and specify characteristics for reference lines. In addition, if the needles drawn from the data points to the base plane complicate a graph, you can suppress them.
You can use global statements to add text to the graph,
and an Annotate data set to enhance the plot.
SCATTER plot-request </ option(s)>; |
y*x=z |
option(s) can be one or more options from any or all of the following categories:
ANNOTATE=Annotate-data-set | |
COLOR='data-point-color' | data-point-color-variable | |
NONEEDLE | |
ROTATE=angle-list | |
SHAPE='symbol-name' | shape-variable | |
SIZE=symbol-size | size-variable | |
TILT=angle-list |
CAXIS=axis-color | |
CTEXT=text-color | |
GRID | |
NOAXIS | NOAXES | |
NOLABEL | |
XTICKNUM=number-of-ticks | |
YTICKNUM=number-of-ticks | |
ZMAX=max-value | |
ZMIN=min-value | |
ZTICKNUM=number-of-ticks |
catalog entry description options:
DESCRIPTION='entry-description' | |
NAME='entry-name' |
Required Arguments |
The SCATTER statement does not require a full grid of observations for the horizontal variable.
Options |
See also: | The Annotate Data Set |
Featured in: | Rotating a Scatter Plot |
If you specify COLOR='data-point-color', all shapes are drawn in that color. For example, the procedure uses BLUE for all graph shapes when you specify
color='blue'
If you specify COLOR=data-point-color-variable, the color of the symbol is determined by the value of the color variable for that observation. For example, the procedure uses the value of the variable CLASS as the color for each data point shape when you specify
color=class
Using COLOR=data-point-color-variable enables you to assign different colors to the shapes to classify data.
Featured in: | Using Shapes in Scatter Plots |
Featured in: | Using Shapes in Scatter Plots |
Featured in: | Using Shapes in Scatter Plots |
n <...n> | |
n TO n <BY increment> | |
n <...n> TO n <BY increment > <n <...n> > |
The values specified in angle-list can be negative or positive and can be larger than 360°. For example, a rotation angle of 45° can also be expressed
rotate=405 rotate=-315
You can specify a sequence of angles to produce separate graphs for each angle. The angles that are specified in the ROTATE= option are paired with any angles that are specified with the TILT= option. If one option contains fewer values than the other, the last value in the shorter list is paired with the remaining values in the longer list.
See also: | TILT= option. |
Featured in: | Rotating a Scatter Plot |
BALLOON | DIAMOND | PRISM |
CLUB | FLAG | PYRAMID |
CROSS | HEART | SPADE |
CUBE | PILLAR | SQUARE |
CYLINDER | POINT | STAR. |
Scatter Plot Symbols illustrates these symbol types with needles.
If you specify SHAPE='symbol-name', all data points are drawn in that shape. For example, the procedure draws all data points as balloons when you specify
shape='balloon'
If you specify SHAPE=shape-variable, the shape of the data point is determined by the value of the shape variable for that observation. For example, the procedure uses the value of the variable CLASS for a particular observation as the shape for that data point when you specify
shape=class
Using SHAPE=shape-variable enables you to assign different shapes to the data points to classify data.
Featured in: | Using Shapes in Scatter Plots |
If you specify SIZE=size-variable, the size of the data point is determined by the value of the size variable for that observation. For example, when you specify SIZE=CLASS, the procedure uses the value of the variable CLASS for each observation as the size of that data point. If you use SIZE=size-variable, you can assign different sizes to the data points to classify data.
Featured in: | Rotating a Scatter Plot |
n <...n> | |
n TO n <BY increment> | |
n <...n> TO n <BY increment > <n <...n> > |
The values that are specified in angle-list must be 0 through 90.
You can specify a sequence of angles to produce separate graphs for each angle. The angles that are specified in the TILT= option are paired with any angles that are specified with the ROTATE= option. If one option contains fewer values than the other, the last value in the shorter list is paired with the remaining values in the longer list.
See also: | ROTATE= option |
Featured in: | Rotating a Scatter Plot |
Featured in: | Rotating a Scatter Plot |
Changing the Appearance of the Points |
Use the COLOR=, SHAPE=, and SIZE= options to change the appearance of your scatter plot or to classify data using color, shape, size, or any combination of these features. Scatter Plot Symbols illustrates the shape names that you can specify in the SHAPE= option.
For example, to make all of the data points red balloons at twice the normal size, use
scatter y*x=z /color='red' shape='balloon' size=2;
To size your points according to the values of the variable TYPE in your input data set, use
scatter y*x=z / size=type;
For an example, see Using Shapes in Scatter Plots.
Simulating an Overlaid Scatter Plot |
For example, suppose you want to graph a data set that contains two values for the vertical variable Z for each combination of variables X and Y. You could produce the original data set with a DATA step like this:
data planes; input x y z shape $; datalines; 1 1 1 PRISM 1 2 1 PRISM 1 3 1 PRISM 2 1 1 PRISM 2 2 1 PRISM 2 3 1 PRISM 3 1 1 PRISM 3 2 1 PRISM 3 3 1 PRISM 1 1 2 BALLOON 1 2 2 BALLOON 1 3 2 BALLOON 2 1 2 BALLOON 2 2 2 BALLOON 2 3 2 BALLOON 3 1 2 BALLOON 3 2 2 BALLOON 3 3 2 BALLOON ;
The SHAPE variable is assigned a different value for each different Z value for a single combination of X and Y values.
Ordinarily, the SCATTER statement only plots the Z value for the last observation for a single combination of X and Y. However, you can use a DATA step to assign a slightly different x, y position to all observations where Z is greater than 1:
data planes2; set planes; if z > 1 then x = x + .000001; run;
Then you can use a SCATTER statement to produce a plot like the one in Simulated Overlaid Scatter Plot:
proc g3d data=planes2; scatter x*y=z / zmin=0 shape=shape; run; quit;
Simulated Overlaid Scatter Plot
Reversing Values on an Axis |
For example, the following code generates the scatter plot shown in Default Y-axis Order:
data original; input y x z; datalines; -1.15 1 .01 -1.00 2 .02 1.20 3 .03 1.25 4 .04 1.50 5 .05 2.10 1 .06 2.15 2 .07 2.20 3 .08 2.25 4 .09 2.30 5 .10 ; title1 'Default Y Axis Order'; /* default Y axis order */ proc g3d data=original; scatter y * x = z; run;
To reverse the Y axis in the plot that is shown in Default Y-axis Order, you can write a DATA step like the following to reverse the Y values and, therefore, reverse the Y axis when the values are plotted:
data minus_y; set original; y=-y; run;
The previous code creates the MINUS_Y data set by reading the ORIGINAL data set, and then multiplying the values of variable Y by -1. Although plotting Y values from the MINUS_Y data set would reverse values on the Y axis, it would misrepresent the original data. Such a plot would label the axis with the negative-Y values. You can correct the problem by using PROC FORMAT to display Y values as they are stored in the ORIGINAL data set:
proc format; picture reverse low - < 0 = '09.00' 0 < - high = '09.00' (prefix='-') 0 = '09.00'; run;
The PICTURE statement defines this new picture format for three data ranges. The lowest value in the data up to but not including zero will display with no prefix, which means negative values will display without a minus sign. All values above (but not including) zero to the highest value in the data will be displayed with the specified prefix, which in this case is a minus sign. Because zero is excluded from both ranges, it is assigned its own picture with no prefix.
You can now assign the REVERSE format to the Y values from the MINUS_Y data set and use Y to generate a scatter plot. The resulting plot displays Y's negative values without a prefix, and its positive values display with a minus sign prefix. This effectively represents Y values as they are stored internally in the ORIGINAL data set, thus correcting the data misrepresentation that results from multiplying Y by -1.
The following code generates the scatter plot shown in Reverse Y-axis Order:
title1 'Reverse Y Axis Order'; /* reverses order of default Y axis */ proc g3d data=minus_y; format y reverse.; scatter y * x = z; run; quit;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.