RATS 11.1
RATS 11.1

The KEY option on GRAPH and SCATTER allows you to add a key (legend) at a choice of several locations. Four of these are outside the graph box (KEY=BELOW, ABOVE, LEFT or RIGHT). Four of these are inside the graph box (UPLEFT, LOLEFT, UPRIGHT, LORIGHT). This second group doesn’t take space away from the graph itself, but you have to be careful to choose a location (if it exists) which doesn’t interfere with the graph.

 

There is also KEY=ATTACHED, which puts the graph labels on the graph itself at locations where the labeling will be as clear as possible. This is available only for a few types of graphs (line, step, and symbols time series graphs).

 

By default, RATS uses the series names for the key labels. If these are cryptic database names, you can provide your own labels on the graph using the KLABELS option.

 

These are the standard options for handling keys:

 

KEY=[NONE]/UPLEFT/UPRIGHT/LOLEFT/LORIGHT/ATTACHED/ABOVE/BELOW/LEFT/RIGHT

KEY controls the placement of the key for the graph. The choices are:

NONE

no key

UPLEFT  

key in upper left corner, inside the graph box

UPRIGHT   

upper right corner, inside

LOLEFT

lower left corner, inside

LORIGHT  

lower right corner, inside

ABOVE

centered above the graph (and any HEADER and SUBHEADER).

BELOW

centered below the graph, and below any X-axis labeling

LEFT       

left side, centered vertically, outside graph and Y-axis labeling

RIGHT

right side, centered vertically, outside graph and Y-axis labeling

ATTACHED
 

used with LINES and SYMBOLS styles, this puts the labels inside the graph near the lines or symbols, at positions where the association of a line with the labels as unambiguous as possible.

 

KLABEL=VECTOR of STRINGS for KEY labels

By default, RATS labels the KEY with the names of the series. Use KLABEL to supply your own labels. You can create the VECTOR[STRINGS] ahead of time, or enter it using the ||..|| matrix notation.


The order of labels in the VECTOR should match the order of the supplementary cards. You can use a double backslash \\\\ in a string to put a line break in the string.
 

[KBOX]/NOKBOX

This controls whether or not a box (border) is drawn around the key.

 

KHEIGHT=height of key box (between 0 and 1)

KWIDTH=width of key box (between 0 and 1)

By default, RATS tries to find the most efficient arrangement for the key, given the number of series in the key, its position, the setting of the GRPARMKEYLABELING parameter, and so on. KHEIGHT and KWIDTH allow you to control the size and proportion of the box by specifying the height and width of the box as a fraction of the graph’s overall height and width. For instance, KHEIGHT=.25,KWIDTH=.50 will use 25% of the height and 50% of the width. You must specify both options.

 

[KSAMPLE]/NOKSAMPLE

NOKSAMPLE eliminates the sample line styles, colors, or fill patterns from the key, leaving only the labels.

 

Examples

This example uses descriptive titles input using KLABELS with in-line matrix notation to provide the VECTOR of STRINGS. The key will be placed below the graph. See the first sample below.

 

graph(header="Comparison of Local Trend Rates",key=below,$

  klabels=||"From HP Filter","From Estimated Local Trend"||) 2

# hprate

# ltrate

 

 

This uses KEY=ATTACHED and also uses KLABELS to provide descriptive titles. This is from an example in the Diebold text, which has a fairly lengthy section on different ways to displaying time series data. This is the second sample below.

 

graph(style=line,key=attached,header="Figure 3.15",$

  klabels=||"AGRICULTURE","RETAIL","SERVICES","MANUFACTURING"||) 4

# ga8gff

# ga8gr

# ga8gs

# ga8gm

 


 

 


Copyright © 2026 Thomas A. Doan