Credits Overview Plotting Styles Commands Terminals

key placement

Key placement options:

      set key {inside | outside | fixed}
              {lmargin | rmargin | tmargin | bmargin}
              {at <position>}}
              {left | right | center} {top | bottom | center}
              {offset <dx>,<dy>}

This section describes placement of the primary, auto-generated key. To construct a secondary key or place plot titles elsewhere, see multiple keys.

To understand positioning, the best concept is to think of a region, i.e., inside/outside, or one of the margins. Along with the region, keywords left/center/right (l/c/r) and top/center/bottom (t/c/b) control where within the particular region the key should be placed. In inside mode, the keywords left (l), right (r), top (t), bottom (b), and center (c) push the key out toward the plot boundary as illustrated here:

     t/l   t/c   t/r
     c/l    c    c/r
     b/l   b/c   b/r

In outside mode, automatic placement is similar to the above illustration, but with respect to the view, rather than the graph boundary. That is, a border is moved inward to make room for the key outside of the plotting area, although this may interfere with other labels and may cause an error on some devices. The particular plot border that is moved depends upon the position described above and the stacking direction. For options centered in one of the dimensions, there is no ambiguity about which border to move. For the corners, when the stack direction is vertical, the left or right border is moved inward appropriately. When the stack direction is horizontal, the top or bottom border is moved inward appropriately.

The margin syntax allows automatic placement of key regardless of stack direction. When one of the margins lmargin (lm), rmargin (rm), tmargin (tm), and bmargin (bm) is combined with a single, non-conflicting direction keyword, the key is positioned along the outside of the page as shown here. Keywords above and over are synonymous with tmargin. Keywords below and under are synonymous with bmargin.

          l/tm  c/tm  r/tm
     t/lm                  t/rm
     c/lm                  c/rm
     b/lm                  b/rm
          l/bm  c/bm  r/bm

For version compatibility, above, over, below, or under without any additional l/c/r or stack direction keyword uses center and horizontal. The keyword outside without any additional t/b/c or stack direction keyword uses top, right and vertical (i.e., the same as t/rm above).

The <position> can be a simple x,y,z as in previous versions, but these can be preceded by one of five keywords (first, second, graph, screen, character) which selects the coordinate system in which the position of the first sample line is specified. See coordinates for more details. The effect of left, right, top, bottom, and center when <position> is given is to align the key as though it were text positioned using the label command, i.e., left means left align with key to the right of <position>, etc.