Statistical Graphics Using ODS


Varying Colors and Markers but Not Lines

Many styles are designed to make color plots where lines, markers, and groups of observations can be distinguished even when the plot is sent to a black-and-white printer. Hence, you can distinguish lines by both their colors and their line patterns. Similarly, you can distinguish markers by both their colors and their symbols. This is not true in the HTMLBLUE, PEARL, PEARLJ, and SAPPHIRE styles, which are all-color styles. You can easily make any style an all-color style by specifying the ATTRPRIORITY= option in the ODS GRAPHICS statement. For more information, see the section Attribute Priorities.

Alternatively, you can make an all-color style by using the %MODSTYLE autocall macro. It creates a new style by modifying a parent style and reordering the colors, line patterns, and marker symbols in the GraphDatan style elements (see the section Some Common ODS Style Elements). The macro is documented in the section ODS Style Template Modification Macro.

The following example illustrates how you can use the macro and is taken from the section Fitting a Curve through a Scatter Plot in Chapter 117: The TRANSREG Procedure. The data come from an experiment in which nitrogen oxide emissions from a single-cylinder engine are measured for various combinations of fuel and equivalence ratio.

The following statements fit separate curves for each group and produce Figure 21.68 and Figure 21.69:

ods graphics on;
ods listing style=htmlblue;

proc transreg data=sashelp.Gas plots=fit(nocli noclm);
   model identity(nox) = class(Fuel / zero=none) * pbspline(EqRatio);
run;

%modstyle(parent=statistical, name=StatColor, linestyles=solid, type=CLM)
ods listing style=StatColor;

proc transreg data=sashelp.Gas plots=fit(nocli noclm);
   model identity(nox) = class(Fuel / zero=none) * pbspline(EqRatio);
run;

The first PROC TRANSREG step uses the HTMLBLUE style to create the fit plot in Figure 21.68, which uses only colors to distinguish each group. Then the macro creates a new style called STATCOLOR, which inherits attributes from the STATISTICAL style.

When you specify TYPE=CLM and LINESTYLES=SOLID, the %MODSTYLE macro varies colors and markers but displays only solid lines. In Figure 21.69, which is created by using the modified style, the groups are differentiated by color and marker type.

Figure 21.68: Fit Plot with the HTMLBLUE Style

Fit Plot with the HTMLBLUE Style


Figure 21.69: Fit Plot with the Modified Style

Fit Plot with the Modified Style