Controlling the Appearance of Non-grouped Data
When you use statements such as SERIESPLOT, BANDPLOT, NEEDLEPLOT,
ELLIPSE, STEPPLOT, FRINGEPLOT, LINEPARM, and VECTORPLOT to draw plots
containing lines, the same style element, GraphDataDefault, is used for all line and
marker properties. You can think of these plots as "non-specialized," and they all have
the same default appearance when used in overlays
The following example produces series lines that have the same default appearance.
proc template;
define statgraph series;
begingraph;
entrytitle "Overlay of Multiple SERIESPLOTs";
layout overlay / yaxisopts=(label="IBM Stock Price");
seriesplot x=date y=high / curvelabel="High";
seriesplot x=date y=low / curvelabel="Low";
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.stocks template=series;
where date between "1jan2002"d and "31dec2005"d
and stock="IBM";
run;
Here is the output.
To ensure that the series lines differ in appearance, you can use any style element with
line properties. A set of carefully constructed style elements named GraphData1–
GraphDataN (where N=12 for most styles, some styles might have fewer) are normally
used for this purpose. These elements all use different marker symbols, line pattern, fill
colors (COLOR=) and line and marker colors (CONTRASTCOLOR=). All line and
marker colors are of different hues but with the same brightness, which means that all
twelve colors can be distinguished but none stands out more than another. Fill colors are
450 Chapter 23 Managing Your Graph’s Appearance
based on the same hue but have less saturation, making them similar but more muted
than the corresponding contrast colors.
In the following layout block, the style elements GraphData1 and GraphData2 are used
to change the default appearance of the series lines in the graph.
layout overlay / yaxisopts=(label="IBM Stock Price");
seriesplot x=date y=high / curvelabel="High" lineattrs=GraphData1;
seriesplot x=date y=low / curvelabel="Low" lineattrs=GraphData2;
endlayout;
Here is example output.
This same graph could also be achieved by specifying CYCLEATTRS=TRUE on the
LAYOUT OVERLAY statement and omitting the LINEATTRS= options on the plot
statements. In that case, the visual attributes for each plot in the overlay are rotated as
described in “Attribute Rotation Patterns” on page 478. The GraphDataN style elements
provide visual distinction. All of these elements vary color, line pattern, and marker
symbols to gain maximum differentiation.
Sometimes, you might not want to vary all properties at once. For example, to force only
the color to change but not the line pattern, you can override one or more properties that
you want to hold constant as shown in the following layout block.
layout overlay / yaxisopts=(label="IBM Stock Price");
seriesplot x=date y=high / curvelabel="High"
lineattrs=GraphData1(pattern=shortdash);
seriesplot x=date y=low / curvelabel="Low"
lineattrs=GraphData2(pattern=shortdash);
endlayout;
Controlling the Appearance of Non-grouped Data 451

Get SAS 9.4 Graph Template Language, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.