Chapter Contents


SAS/GRAPH Software: Reference

Specifying Colors in SAS/GRAPH Programs

When you explicitly specify a color on a SAS procedure or statement, SAS/GRAPH uses that color, provided your device can display it. If you do not specify color, or if SAS/GRAPH needs more colors than are specified, it uses default colors specified on the GOPTIONS statement, or colors from the current colors list.

Specifying Default Colors in a GOPTIONS Statement

The GOPTIONS statement has several graphics options that specify default colors for graphics elements:

Option Sets default color for
CBACK= background for graphics output
CBY= BY lines in graphics output
CSYMBOL= SYMBOL statements
CTEXT= all text and the border in graphics output
CTITLE= border, plus all titles, footnotes, and notes

SAS/GRAPH software uses these values if you do not explicitly select colors in other statements. Refer to Graphics Options and Device Parameters Dictionary for complete information about each of these graphics options.

If you do not explicitly specify color in a SAS statement or set a default color for a graphic element in the graphics output, SAS/GRAPH software searches for a colors list.

Defining and Using a Colors List

If SAS/GRAPH software does not find a color specification on a procedure or statement, or a default for the graphic elements used in the output, it uses colors from the colors list, which it sequentially looks for in two places:

  1. the COLORS= option on a GOPTIONS statement

  2. the device's default color list.

The color selected from the colors list varies depending on the procedure using the color and the graphics element that is being drawn. Usually, the first color in the list is used; however, certain procedures may select other colors. For example, if the CAXIS= option is not specified in the GCONTOUR procedure's PLOT statement, the procedure selects the second color from the colors list to draw the axes.

Building a Colors List

To build a colors list, use the COLORS= option on the GOPTIONS statement. This specified colors list overrides the current device's default colors list. Building a colors list is useful for selecting a subset of colors to be used in a specific order for graphics output. For example, to ensure that the colors red, green, and blue are available in that order, you can specify:

goptions colors=(red green blue);

A specified color value must not exceed eight characters and must be in a valid SAS color-naming scheme (see Color-naming Schemes).

Note:   The COLORS= graphics option only provides a default lookup table. Any time you explicitly select any other colors in your SAS/GRAPH program, those colors are used to draw the graphics elements for which you have selected them.  [cautionend]

For a pen plotter, SAS/GRAPH software uses the order of the colors in the COLORS= graphics option to define the order of pens for a multiple pen plotter, or to make a pen plotter prompt you to change the pen when a graph uses more colors than the plotter has.

Using a Device's Default Colors List

If you do not define a colors list with the COLORS= graphics option, SAS/GRAPH software uses the default colors list for your device. This colors list is found in the device entry of the specified device driver (for details on specifying a device driver, refer to The GDEVICE Procedure). If you select a different device driver during a SAS session, the colors list changes unless you have specified the COLORS= graphics option.

To view and modify the device's default colors list, use the GDEVICE procedure (for details, refer to The GDEVICE Procedure).

Overriding the Default Colors List

If you do not specify colors for certain graphics elements or a colors list with the COLORS= graphics option, SAS/GRAPH procedures assign colors from the device's default colors list. In some procedures, this assignment takes up some of the 256 colors that you can specify for a graph. For example, if no colors are specified, the G3D procedure uses the first 3 colors from the colors list to draw the text, the plot axes, and the plot symbols. These colors take up 3 of the 256 colors that you can specify for the graph. Therefore, you can specify 253 additional colors for your graph before a warning is issued and the colors are remapped.

To use only the colors that you explicitly specify, submit

goptions colors=(none);

This causes colors to be used only as they are encountered in your SAS program. This is useful if you want to generate graphics output with the maximum of 256 colors, and you do not want to use any of the device's default colors. It also prevents a procedure from using up some of the 256 colors with the default colors list and prevents SAS/GRAPH software from remapping colors because too many colors were specified.

Resetting the Colors List to the Default

If you have specified a colors list with the COLORS= graphics option and you want to reset it back to the default colors list for your device, specify

goptions colors=();

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.