Key

The set key command enables a key (or legend) containing a title and a sample (line, point, box) for each plot in the graph. The key may be turned off by requesting set key off or unset key. Individual key entries may be turned off by using the notitle keyword in the corresponding plot command. The text of the titles is controlled by the set key autotitle option or by the title keyword of individual plot and splot commands. See plot title (p. [*]) for more information.

Syntax:

     set key {on|off} {default}
           {{inside | outside | fixed} | {lmargin | rmargin | tmargin | bmargin}
             | {at <position>}}
           {left | right | center} {top | bottom | center}
           {vertical | horizontal} {Left | Right}
           {{no}enhanced}
           {{no}opaque {fc <colorspec>}}
           {{no}reverse} {{no}invert}
           {samplen <sample_length>} {spacing <line_spacing>}
           {width <width_increment>} {height <height_increment>}
           {{no}autotitle {columnheader}}
           {title {"<text>"} {{no}enhanced} {center | left | right}}
           {font "<face>,<size>"} {textcolor <colorspec>}
           {{no}box {linestyle <style> | linetype <type> | linewidth <width>}}
           {maxcols {<max no. of columns> | auto}}
           {maxrows {<max no. of rows> | auto}}
     unset key
     show key

Elements within the key are stacked according to vertical or horizontal. In the case of vertical, the key occupies as few columns as possible. That is, elements are aligned in a column until running out of vertical space at which point a new column is started. The vertical space may be limited using 'maxrows'. In the case of horizontal, the key occupies as few rows as possible. The horizontal space may be limited using 'maxcols'.

By default the key is placed in the upper right inside corner of the graph. The keywords left, right, top, bottom, center, inside, outside, lmargin, rmargin, tmargin, bmargin (, above, over, below and under) may be used to automatically place the key in other positions of the graph. Also an at 4#4position5#5 may be given to indicate precisely where the plot should be placed. In this case, the keywords left, right, top, bottom and center serve an analogous purpose for alignment. For more information, see key placement (p. [*]).

Justification of the plot titles within the key is controlled by Left or Right (default). The text and sample can be reversed (reverse) and a box can be drawn around the key (box {...}) in a specified linetype and linewidth, or a user-defined linestyle.

The text in the key is set in enhanced mode by default, this can be changed with the {no}enhanced option, also independently for the key title only and for each individual plot.

By default the key is built up one plot at a time. That is, the key symbol and title are drawn at the same time as the corresponding plot. That means newer plots may sometimes place elements on top of the key. set key opaque causes the key to be generated after all the plots. In this case the key area is filled with background color or the requested fill color and then the key symbols and titles are written. The default can be restored by set key noopaque.

By default the first plot label is at the top of the key and successive labels are entered below it. The invert option causes the first label to be placed at the bottom of the key, with successive labels entered above it. This option is useful to force the vertical ordering of labels in the key to match the order of box types in a stacked histogram.

The 4#4height_increment5#5 is a number of character heights to be added to or subtracted from the height of the key box. This is useful mainly when you are putting a box around the key and want larger borders around the key entries.

An overall title can be put on the key (title "4#4text5#5") — see also syntax (p. [*]) for the distinction between text in single- or double-quotes. The justification of the title defaults to center and can be changed by the keywords right or left

The defaults for set key are on, right, top, vertical, Right, noreverse, noinvert, samplen 4, spacing 1, notitle, and nobox. The default 4#4linetype5#5 is the same as that used for the plot borders. Entering set key default returns the key to its default configuration.

Each plot is represented in the key by a single line containing a line or symbol or shape representing the plot style and a corresponding title. Using the keyword notitle in the plot command will suppress generation of the line. Contour plots generated additional entries in the key, one for each contour (see cntrlabel (p. [*])). You can add extra lines to the key by inserting a dummy plot command that uses the keyword keyentry rather than a filename or a function. See keyentry (p. [*]).

When using the TeX/LaTeX group of terminals or terminals in which formatting information is embedded in the string, gnuplot can only estimate the width of the string for key positioning. If the key is to be positioned at the left, it may be convenient to use the combination set key left Left reverse.



Subsections