Chapter Contents |
Previous |
Next |
SAS/GRAPH Software: Reference |
Global
LEGEND statements specify the characteristics of a legend but do not create legends. These characteristics are
LEGEND definitions are not automatically applied when a procedure generates a legend. Instead, they must be explicitly assigned with a LEGEND= option in the appropriate procedure statement.
illustrates the terms associated with the various parts of a legend.
Parts of a Legend
LEGEND<1...99><options>; |
option(s) can be one or more options from any or all of the following categories:
ACROSS=number-of-columns | |
CBLOCK=block-color | |
CBORDER=frame-color | |
CFRAME=background-color | |
CSHADOW=shadow-color | |
DOWN=number-of-rows | |
FRAME | |
FWIDTH=thickness-factor | |
SHAPE=BAR(width,height) <units> | LINE(length) <units> | SYMBOL(width,height) <units> |
MODE=PROTECT | RESERVE | SHARE | |
OFFSET=(<x ><,y >)<units > | (<x <units >><,y <units >>) | |
ORIGIN=(<x ><,y >)<units > | (<x <units >><,y <units >>) | |
POSITION=(<BOTTOM | MIDDLE | TOP> <LEFT | CENTER | RIGHT> <INSIDE | OUTSIDE>) |
LABEL=(text-argument(s)) | NONE | |
ORDER=(value-list) | |
VALUE=(text-argument(s)) | NONE |
When the syntax of an option includes units, use one of these:
CELLS | character cells |
CM | centimeters |
IN | inches |
PT | points |
PCT | percentage of the graphics output area |
If you omit units, a unit specification is searched for in this order:
Featured in: | Example 8. Creating a Simple Web Page with the ODS HTML Statement |
CBLOCK= and CSHADOW= are mutually exclusive. If both are present, SAS/GRAPH software uses the last one specified. CBLOCK= is usually used in conjunction with the FRAME, CFRAME=, or CBORDER= options.
See also: | Creating Drop Shadows and Block Effects and the OFFSHADOW= graphics option |
CSHADOW= and CBLOCK= are mutually exclusive. If both are present, SAS/GRAPH uses the last one specified. CSHADOW= is usually specified in conjunction with the FRAME, CFRAME=, or CBORDER= options.
See also: | Creating Drop Shadows and Block Effects and the OFFSHADOW= graphics option |
COLOR=text-color | |
FONT=font | NONE | |
HEIGHT=text-height <units> | |
JUSTIFY=LEFT | CENTER | RIGHT | |
POSITION=(<BOTTOM | MIDDLE | TOP> <LEFT | CENTER | RIGHT>) |
See Text Description Suboptions for complete descriptions.
Specify as many text strings and text description suboptions as you want, but enclose them all in one set of parentheses.
Featured in: | Example 3. Rotating Plot Symbols through the Colors List and Example 8. Creating a Simple Web Page with the ODS HTML Statement |
PROTECT | draws the legend in the procedure output area, but a blanking area surrounds the legend, preventing other graphics elements from being displayed in the legend. (A blanking area is a protected area in which no other graphics elements are displayed.) |
RESERVE | takes space for the legend from the procedure output area, thereby reducing the amount of space available for the graph. If MODE=RESERVE is specified in conjunction with OFFSET=, the legend may push the graph off the graphics output area. RESERVE is valid only when POSITION=OUTSIDE. If POSITION=INSIDE is specified, a warning is issued and MODE= is changed to PROTECT. |
SHARE | draws the legend in the procedure output area. If the legend is positioned over elements of the graph itself, both graphics elements and legend elements are displayed. |
By default, MODE=RESERVE unless POSITION=INSIDE, in which case the default changes to MODE=PROTECT.
See also: | Positioning the Legend |
Featured in: | Example 8. Creating a Simple Web Page with the ODS HTML Statement |
To set only the x offset, specify one value, with or without a following comma:
offset=(4 cm,)
To set both the x and y offset, specify two values, with or without a comma separating them:
offset=(2 pct, 4 pct)
To set only the y offset, specify one value preceded by a comma:
offset=(,-3 pct)
OFFSET= is usually used in conjunction with POSITION= to adjust the position of the legend. Moves are relative to the location specified by POSITION=, with OFFSET=(0,0) representing the initial position. You can also apply OFFSET= to the default legend position.
OFFSET= is unnecessary with ORIGIN= since ORIGIN= explicitly positions the legend and requires no further adjustment. However, if you specify both options, the values of OFFSET= are added to the values of ORIGIN=, and the LEGEND is positioned accordingly.
See also: | Positioning the Legend and the option POSITION= |
n <...n> | |
n TO n <BY increment> | |
n <...n> TO n <BY increment> <n <...n>> |
If a numeric variable has an associated format, the specified values must be the unformatted values.
'value-1' <...'value-n'> |
If a character variable has an associated format, the specified values must be the formatted values.
For a complete description of value-list, see the ORDER= option in the AXIS statement.
Even though ORDER= controls whether a legend value is displayed and where it appears, the VALUE= option controls the text that the legend value displays.
To set only the x coordinate, specify one value, with or without a following comma:
origin=(4 cm,)
To set both the x and y coordinates, specify two values, with or without a comma separating them:
origin=(2 pct, 4 pct)
To set only the y coordinate, specify one value preceded by a comma:
origin=(,3 pct)
ORIGIN= overrides the POSITION= option if both are used. Although using the OFFSET= option with the ORIGIN= option is unnecessary, if OFFSET= is also specified, it is applied after the ORIGIN= request has been processed.
See also: | Positioning the Legend |
Featured in: | Example 8. Creating a Simple Web Page with the ODS HTML Statement |
OUTSIDE or INSIDE | specifies the location of the legend in relation to the axis area. |
BOTTOM or MIDDLE or TOP | specifies the vertical position. |
LEFT or CENTER or RIGHT | specifies the horizontal position. |
By default, POSITION=(BOTTOM CENTER OUTSIDE). You can change one or more settings. If you supply only one value the parentheses are not required. If you specify two or three values and omit the parentheses, SAS/GRAPH accepts the first value and ignores the others.
Once you assign the initial legend position, you can adjust it with the OFFSET= option.
The ORIGIN= options overrides POSITION=. The value of the MODE= option can affect the behavior of POSITION=.
See also: | Positioning the Legend and the OFFSET= option and the MODE= option |
Featured in: | Example 3. Rotating Plot Symbols through the Colors List and Example 8. Creating a Simple Web Page with the ODS HTML Statement |
shape=symbol(.5,.5)
This specification produces legend values like the ones in Legend Values Produced with SHAPE= SYMBOL(b):
shape=symbol(2,.5)
Legend Values Produced with SHAPE= SYMBOL
By default, width is 5, height is 1, and units are CELLS. You can specify units for the width,height pair or for the individual coordinates.
Featured in: | Example 3. Rotating Plot Symbols through the Colors List |
NONE suppresses the value descriptions although the legend values (bars, lines, and so on) are still displayed. Text-argument(s) can be one or more of these:
Specified text strings are assigned to the legend values in order. If you submit only one string, only the first legend entry uses the value of that string. If you specify multiple strings, the first string is the text for the first entry; the second string is the text for the second entry; and so forth. For example, this specification produces legend entries like those shown in Specifying Value Descriptions with the VALUE= Option:
value=('1986' '1987' '1988')
Specifying Value Descriptions with the VALUE= Option
COLOR=text-color | |
FONT=font | NONE | |
HEIGHT=text-height <units > | |
JUSTIFY=LEFT | CENTER | RIGHT | |
TICK=n |
See Text Description Suboptions for complete descriptions.
Place text description suboptions before the text strings they modify. Suboptions not followed by a text string affect the default values. To specify and describe the text for individual values or to produce multi-line text, use the TICK= suboption.
Specify as many text strings and text description suboptions as you want, but enclose them all in one set of parentheses.
To order or select legend entries, use the ORDER= option.
See also: | Text Description Suboptions and the option ORDER= |
Text description suboptions are used by the LABEL= and VALUE= options to change the color, height, justification, font, and angle of either default text or specified text strings. See LABEL= and VALUE=.
You can use JUSTIFY= to print multiple lines of text by repeating JUSTIFY= before the text string for each line. For example, this statement produces a legend label and value descriptions like those shown in Specifying Multiple Lines of Text with the JUSTIFY= Suboption:
legend label=(justify=c 'Distribution' justify=c 'Centers') value=(tick=1 justify=c 'Portland,' justify=c 'Maine' tick=2 justify=c 'Paris,' justify=c 'France' tick=3 justify=c 'Sydney,' justify=c 'Australia');
Specifying Multiple Lines of Text with the JUSTIFY= Suboption
Specify additional suboptions before any string.
See also: | the TICK= suboption |
The parentheses are not required if only one value is supplied. If you specify two or three values and omit the parentheses, SAS/GRAPH accepts the first value and ignores the others.
Using the POSITION= Suboption with Multi-line Legend Labels shows some of the ways POSITION= affects a multi-line legend label in which the entries are stacked in a column (ACROSS=1). This figure uses a label specification such as
label=('multi-' justify=left 'line' justify=left 'label' position=left)
In this specification, POSITION= specifies the default value, LEFT, which is represented by the first legend in the figure. The value of POSITION= is indicated above each legend. The default justification is used unless you also use the JUSTIFY= suboption.
Using the POSITION= Suboption with Multi-line Legend Labels
Minneapolis
, specify
value=(tick=3 'Minneapolis')
The characteristics of all other value descriptions remain unchanged.
If you use TICK= when you designate text for one legend entry, you must also use it when you designate text for any additional legend entries. For example, this option changes the text of both the second and third legend entries:
value=(tick=2 'Paris' tick=3 'Sydney')
If you omitted TICK=3, the text of the second legend
entry would be
ParisSydney
.
Text description suboptions that precede TICK= affect all the value descriptions for the legend unless the same suboption (with a different value) follows a TICK= specification. Text description suboptions that follow TICK= affect only the specified legend entry. For example, suppose you specify this option for a legend with three entries:
value=(color=red font=swiss tick=2 color=blue)
The text of all three entries would use the Swiss font; the first and third entries would be red and only the second entry would be blue.
label=(font=swiss height=4 'Weight' justify=right height=3 '(in tons)')
FONT=SWISS applies to both
Weight
and
(in tons)
. HEIGHT=4 affects
Weight
, but is respecified
as HEIGHT=3 for
(in tons)
. JUSTIFY=RIGHT
affects only
(in tons)
.
Using the LEGEND Statement |
LEGEND statements can be located anywhere in your SAS program. They are global and remain in effect until canceled or until you end your SAS session. LEGEND statements are not applied automatically, and must be explicitly assigned by an option in the procedure that uses them.
You can define up to 99 different LEGEND statements. If you define two LEGEND statements of the same number, the most recently defined one replaces the previously defined statement of the same number. A LEGEND statement without a number is treated as a LEGEND1 statement.
Cancel individual LEGEND statements by defining a LEGEND statement of the same number without options (a null statement):
legend4;
Canceling one LEGEND statement does not affect any other LEGEND definitions. To cancel all current LEGEND statements, use RESET= in a GOPTIONS statement:
goptions reset=legend;
Specifying RESET=GLOBAL or RESET=ALL cancels all current LEGEND definitions as well as other settings.
To display a list of current LEGEND definitions in the LOG window, use the GOPTIONS procedure with the LEGEND option:
proc goptions legend nolist; run;
Positioning the Legend |
By default, the legend shares the procedure output area with
the procedure output, such as a map or bar chart. (See Placement of Graphic Elements in the Graphics Output Area.) However, several
LEGEND statement options allow you to position a legend anywhere on the graphics
output area and even to overlay the procedure output. This section describes
these options and their effect on each other.
There are two ways you can position the legend on the graphics output area:
The values of the POSITION= option affect the legend in two ways:
Legend Positions Inside the Axis Area shows the legend positions inside the axis area.
Legend Positions Inside the Axis Area
Legend Positions Outside the Axis Area shows legend positions outside the axis area.
Legend Positions Outside the Axis Area
The default combination is POSITION=(BOTTOM CENTER OUTSIDE). The combination (OUTSIDE MIDDLE CENTER) is not valid.
Use OFFSET=(x,y) to adjust the position of the legend specified by POSITION=. The x value shifts the legend either left or right and the y value shifts the legend either up or down.
The offset values are always applied after
the POSITION= request. For example, if POSITION=(TOP RIGHT OUTSIDE), the legend
is located in the upper right corner of the graphics output area. If OFFSET=(0,0)
is specified, the legend does not move. If OFFSET=(-5,-8)CM, the legend moves
5 centimeters to the left and 8 centimeters down.
Use ORIGIN=(x,y)
to specify the coordinates of the exact location of the lower left corner
of the legend box. Because ORIGIN=(0,0) is the lower left corner of the graphics
output area, the values of x and y must be positive.
If you specify negative values, a warning is issued and the default value
is used.
By default, the legend is inside the procedure output area and the space it occupies reduces the size of the graph itself. To control the way the legend relates to the other elements of the graph, use the MODE= option. These are values for MODE=:
You cannot specify both POSITION=INSIDE and MODE=RESERVE because MODE=RESERVE assumes the legend is outside the axis area, and POSITION=INSIDE positions the legend inside the axis area. Therefore, when you specify POSITION=INSIDE, change the value of MODE= to SHARE or PROTECT. Otherwise, SAS/GRAPH issues a warning and automatically changes the value of MODE= to PROTECT.
Creating Drop Shadows and Block Effects |
The value of x determines how far the shadow or block extends to the right (positive numbers) or to the left (negative numbers) of the legend. The value of y determines how far the shadow or block extends above (positive numbers) or below (negative numbers) the legend. If OFFSHADOW=(0,0) is specified, the shadow or block is not visible.
By default, OFFSHADOW=(0.0625, -0.0625) IN; that is, the shadow or block extends 1/16th of an inch to the right and 1/16th of an inch below the legend.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.