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 Priority and Overriding How Groups Are Distinguished.

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 126, 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 64 and Figure 65:

ods graphics on;
ods html style=htmlblue; * You can instead specify other destinations
                           such as LISTING, PDF, or RTF;
proc transreg data=sashelp.Gas plots=fit(nocli noclm);
   model identity(nox) = class(Fuel / zero=none) * pbspline(EqRatio);
run;
ods html close;

%modstyle(parent=statistical, name=StatColor, linestyles=solid, type=CLM)
ods html style=StatColor;
proc transreg data=sashelp.Gas plots=fit(nocli noclm);
   model identity(nox) = class(Fuel / zero=none) * pbspline(EqRatio);
run;
ods html close;

The first PROC TRANSREG step uses the HTMLBLUE style (which is an ATTRPRIORITY='Color' style) to create the fit plot in Figure 64, which uses only colors to distinguish each group. Then the macro creates a new style called STATCOLOR, which inherits attributes from the STATISTICAL style (which is an ATTRPRIORITY='None' style).

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

Figure 64: Fit Plot with the HTMLBLUE Style

Fit Plot with the HTMLBLUE Style


Figure 65: Fit Plot with the Modified Style

Fit Plot with the Modified Style


Last updated: December 09, 2022