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}
           {{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 position 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 and then the key symbols and titles are written. Therefore the key itself may obscure portions of some plot elements. 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 height_increment 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 "text") -- 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 linetype is the same as that used for the plot borders. Entering set key default returns the key to its default configuration.

The key is drawn as a sequence of lines, with one plot described on each line. On the right-hand side (or the left-hand side, if reverse is selected) of each line is a representation that attempts to mimic the way the curve is plotted. On the other side of each line is the text description (the line title), obtained from the plot command. The lines are vertically arranged so that an imaginary straight line divides the left- and right-hand sides of the key. It is the coordinates of the top of this line that are specified with the set key command. In a plot, only the x and y coordinates are used to specify the line position.

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
Build Daemon 2017-11-09