Previous Page | Next Page

Controlling The Appearance of Your Graphs

Using the Statistical Graphics Procedures Options


Overview of the Appearance Options

ODS styles control the overall appearance of the graphs. Visual attributes of various elements of the graph are derived from specific style elements within the style unless explicitly specified in your procedure code. You can make a specific appearance change to one or more aspects of your graph without making changes to the overall style by using appearance options in your procedure options.

Many SG procedure statements have options and suboptions that control the appearance of different parts of a graph. For example, the option LINEATTRS=, the suboption PATTERN=, and the suboption COLOR= in the following DENSITY statement specify that the density curve has a blue dashed line, no matter what style is being used:

density xvar / lineattrs=(pattern=dash color=blue);

Note:   Although you can hardcode values with appearance options, it is not always appropriate to do so. See Specifying Hardcoded Values for more information.  [cautionend]

The appearance options and their values are specific to each statement. For complete documentation for the statements and their options, see the syntax section for the appropriate procedure and statement.

Specifying Appearance Option Values

Default visual attributes of various graphical elements of a graph are derived from the specific style elements of the active style. For example, the text of the markers of a non-grouped scatter plot derive their visual attributes from the GraphDataText style element. Although there are many graphical elements that derive their visual attributes from specific style elements, the following figure shows the style elements that affect graphical text:

[untitled graphic]

However, you can explicitly specify the visual attributes to be used for the various graphical style elements by using the appropriate appearance option for the statement. For example, the MARKERATTRS= appearance option controls the attributes of markers for the SCATTERPLOT statement. All appearance options have suboptions that control a specific aspect of the graphical element. For example, for markers, the MARKERATTRS= option has the suboptions SYMBOL=, COLOR=, and SIZE=, which control those aspects of the marker.

You can specify values for appearance options by using three different methods. The first method uses style element references to set visual attributes. The second method uses hardcoded values. The third method combines the first two methods. It is strongly recommended that you use style references to ensure that your graphs are stylistically robust. Use the hardcoded method only when absolutely necessary. The methods are:

It is recommended that you use style references with appearance options. This is because the style attributes that are referenced by the style element reference are chosen to provide consistency and appropriate emphasis based on display principles for statistical graphics. If you hardcode a value into a style element, you are overriding the style and you might create a graph that is inconsistent with the style. For a table of valid style elements to use with ODS statistical graphics, see Style Elements for Use with ODS Statistical Graphics.


Specifying Style Element References

You can change the visual attributes used for a graphical element of your plot by using the relevant appearance option for a specific statement. You can use style elements as values for any appearance option. Style elements are a collection of style attributes that apply to a particular part of the graph. For example, a style element might contain instructions for the presentation of marker, such as color, symbol, and size. They are contained within the style. For more information about style elements, see the chapter on creating styles in SAS Output Delivery System: User's Guide. When you reference a style element, all of the attributes in that element are used to modify the visual attributes of the graphical feature.

For example, the graph shown in Histogram with Default Density Curve is a histogram with a normal density curve. By default, the visual attributes of the density curve are specified by the style attributes within the style element GraphFit.

Histogram with Default Density Curve

[Histogram with Default Density Curve]

You can use the LINEATTRS= option in the first DENSITY statement to change the style element that is used for the line attributes. For example, when you are using the Default style, specifying the GraphData5 style element causes the density curve line to use the DashDashDot line pattern and the color blue.

 density salary / lineattrs=graphdata5;

Histogram with Density Curve, Using a Specific Style Reference

[Histogram with Density Curve, Using a Specific Style Reference]

In general, it is recommended to specify the entire style element this way to derive all of the relevant visual attributes. In this case, the line pattern and color are both derived from the specified style element.


Specifying Hardcoded Values

In some cases it is important to have a specific visual effect, but it is not necessary for the plot to be reused with different styles. In such a case you can specify hardcoded values for the visual attributes in the appearance option. In the above example from Specifying Style Element References, you could have used the following statement to set the density curve attributes:

density / lineattrs=(pattern=dashdashdot color=blue);

However, if you use the STYLE= option to change the overall style to Journal, which only uses gray scale colors, the color for this curve is still blue:

Using Hardcoded Values with the Journal Style

[Using Hardcoded Values with the Journal Style]

Also, a hardcoded color could be exactly the same color as the wall color of another style, and become indistinguishable from the wall.

Previous Page | Next Page | Top of Page