Previous Page | Next Page

Controlling The Appearance of Your Graphs

Modifying a Style


Using the TEMPLATE Procedure

Within the TEMPLATE procedure, you can use the DEFINE STYLE statement to create a completely new style or you can start from an existing style. When you create styles from existing styles, you can modify the individual style elements.

For complete documentation on using PROC TEMPLATE to modify and create styles, see TEMPLATE Procedure: Creating a Style Definition in SAS Output Delivery System: User's Guide.


Example: Modifying a Style Element

The style element GraphData1 is defined in the Default style as follows:

proc template;  
   define style Styles.Default; 
        ...more style elements... 
   class GraphData1 /  
           markersymbol = "circle"  
           linestyle = 1 
           contrastcolor = GraphColors('gcdata1') 
           color = GraphColors('gdata1'); 

You can use the DEFINE STYLE statement in the TEMPLATE procedure to create a new style from the Default style and modify the GraphData1 style element. The following program creates the new style MyStyleDefault, which inherits all of its style elements and style attributes from the Default style, and modifies the GraphData1 style element:

proc template; 
   define style MyStyleDefault;
   parent=Styles.Default;   
   style GraphData1 from GraphData1 /   
         markersymbol = "triangle"  
         linestyle = 2 
         contrastcolor = GraphColors("gcdata1") 
         color = GraphColors("gdata1"); 
    end;
run;

The new GraphData1 uses the same colors as the original GraphData1, but specifies a different marker symbol and line style.

To use the new MyStyleDefault style for HTML output, specify the STYLE= option:

ods html style=MyStyleDefault;


Ways to Modify Graph Fonts Or Colors Specified By Styles

There are different ways to change the fonts or colors used by a style. Which method you choose depends on how extensively you want to change the font or color specifications used in your output. You can do any of the following:


Modifying the GraphFonts And GraphColors Style Elements

The attributes in the GraphFonts and GraphColors style elements are used as the values for specific style elements elsewhere in the style. In other words, the GraphFonts and GraphColors elements are abstract elements. They are used to assign values to other elements.

For example, the GraphFonts element could be defined follows:

class GraphFonts 
         "Fonts used in graph styles" /  
         'GraphDataFont' = ("<sans-serif>, <MTsans-serif> ",7pt)  
         'GraphValueFont' = ("<sans-serif>, <MTsans-serif>",9pt) 
         'GraphLabelFont' = ("<sans-serif>, <MTsans-serif> ",10pt,bold) 
         'GraphFootnoteFont' = ("<sans-serif>, <MTsans-serif>",10pt) 
         'GraphTitleFont' = ("<sans-serif>, <MTsans-serif>",11pt,bold);

Each attribute, GraphDataFont, GraphValueFont, GraphLabelFont, and so on, defines a list of fonts for use by SAS/GRAPH whenever the corresponding attribute is referenced. These attributes are specified elsewhere in the style as the value of a another font attribute. (For information on the syntax used in the GraphFonts style element, see Font Specifications In The GraphFonts Style Element.)

For example, the GraphValueText element specifies the font and color for tick mark values and legend value descriptions. Suppose the GraphValueText element is defined as follows:

class GraphValueText / 
         font = GraphFonts('GraphValueFont') 
         color = GraphColors('gtext');

The font and color for GraphValueText are specified by elements in the GraphFonts and GraphColors style elements.

GraphFonts('GraphValueFont')

tells SAS/GRAPH to use the font specified by the GraphValueFont attribute in the GraphFonts style element.

GraphColors('gtext')

tells SAS/GRAPH to use the color specified by the gtext attribute in the GraphColors style element.

To change the font and color for tick mark values and legend value descriptions, you could modify either of the following:

However, because elements in GraphFonts and GraphColors are referred to by other elements in the style, changing the values in GraphFonts and GraphColors result in more extensive changes than modifying a specific style element such as GraphValueText directly. If you modify the GraphValueText element directly, your modifications affect only the items controlled by GraphValueText. If you modify the GraphValueFont or gtext attributes, then your modifications might affect other portions of the graph in addition to tick mark values and legend value descriptions. This list includes pie labels, regression equations, data point labels, bar labels, and graph titles.

The styles supplied with SAS/GRAPH are designed to provide a consistent visual appearance for all graphical elements in your output. Modifying attributes in the GraphFonts or GraphColors elements instead of modifying several specific style elements makes it easier to maintain the consistent appearance in your output.

The tables listed in Graphical Style Element Reference for Device-Based Graphics describe the portions of SAS/GRAPH output that are affected by elements and attributes defined in the styles.

Previous Page | Next Page | Top of Page