For the SGPLOT and SGPANEL
procedures, many plots use the same style element, GraphDataDefault,
for graphics elements such as lines, bars, and markers. These plots
have the same default appearance.
In
the graph that is produced by the following code, the bar chart and line chart
use visual attributes from the GraphDataDefault element. The visual
attributes for the line (and markers if specified) are designed to
coordinate with the bar fill areas.
Default Appearance of Non-Grouped Bars and Lines
|
ods graphics on / width=4.5in;
proc sgplot data=sashelp.stocks
(where=(date >= "01jun2005"d
and stock = "IBM"));
title "Stock Volume vs. Close";
vbar date / response=volume;
vline date / response=close y2axis;
run;
title;
|
However, when identical
plot types are overlaid, the procedures instead use style elements
named GraphData1 to GraphData
n (where
n=12 for most styles).
In the following graph,
the series lines have different colors and are easy to distinguish.
The plots use the GraphData1, GraphData2, and GraphData3 style elements.
Default Appearance When Three Series Plots Are Overlaid
|
ods graphics on / width=4.5in;
proc sgplot data=sashelp.stocks
(where=(date >= "01jan2004"d
and stock = "IBM"));
title "Stock Trend";
series x=date y=close;
series x=date y=low;
series x=date y=high;
run;
title;
|
The GraphData
n style
elements use different marker symbols and fill colors to ensure that
the plots differ in appearance. All line and marker colors are of
different hues but with the same brightness, which means that all
12 colors can be distinguished but none stands out more than another.
Fill colors are based on the same hue but have less saturation, making
them similar but more muted than the corresponding contrast colors.
Line patterns can also
vary depending on the style that is used for the graph. Some styles
vary line patterns so that elements in color plots can be distinguished
even when the plot is sent to a black-and-white printer. Line patterns
do not vary for the HTMLBlue style or any style that is defined with
the ATTRPRIORITY="Color" option.
Note: If you have a bar-line overlay
with multiple lines, the lines cycle through GraphData
n,
whereas the bar remains GraphDataDefault.
Other plots use more
specialized style elements for their appearance. For example, the
line attributes for density, loess, PBSpline, and regression curves
are determined by the GraphFit style element.
Here are some interactions
for plots with specialized style elements:
-
If you have a histogram with multiple
density curves, the curve style pattern changes with the number of
curves. For one curve, GraphFit is used. For two curves, GraphFit
and GraphFit2 are used. For three or more, all curves switch over
to GraphData
n The histogram
uses GraphDataDefault.
-
If you have multiple fit plots
(loess, regression, or PBSpline), the behavior is like the density
curves. For one fit, GraphFit is used. For two fits, GraphFit and
GraphFit2 are used. For three or more, all fits switch to GraphData
n.
(This behavior also applies to the SGSCATTER procedure when multiple
fits are specified.)
-
If you have multiple ellipses overlaid
on another plot (such as a scatter), the ellipses cycle through GraphData
n,
whereas the plot uses GraphDataDefault.
In general, if all of
the plots have the same statement name (all scatter, all series, and
so on), then the plots automatically cycle.
The CYCLEATTRS | NOCYCLEATTRS
options in the SGPLOT and SGPANEL procedure statements can be used
to manually control whether the plots have unique attributes. CYCLEATTRS
forces cycling in situations where cycling is not automatic. The NOCYCLEATTRS
option forces cycling to be off. These options are described in the
next section.