By default, plots are displayed with a legend in their top-right corners. The textual description of each dataset is drawn by default from the command used to plot it. Alternatively, the user may specify his own description for each dataset by following the plot command with the title modifier, as follows:
plot sin(x) title 'A sine wave' plot cos(x) title ''
In the lower case, a blank title is specified, in which case, PyXPlot makes no entry for this dataset in the legend. This is useful if it is desired to place some but not all datasets into the legend of a plot. Alternatively, the production of the legend can be completely turned off for all datasets, by the command set nokey. The opposite effect can be achieved by the set key command.
This latter command can also be used to dictate where on the plot the legend should be placed, using a syntax along the lines of:
set key top right
The following recognised positioning keywords are self-explanatory: top, bottom, left, right, xcentre and ycentre. The word outside places the key outside the plot, on its right side. The word below places the legend below the plot.
In addition, two positional offset coordinates may be specified after such keywords – the first value is assumed to be an -offset, and the second a
-offset, in units approximately equal to the size of the plot. For example:
set key bottom left 0.0 -0.5
would display a key below the bottom left corner of the graph.
By default, entries in the key are placed in a single vertical list. They can instead be arranged into a number of columns by means of the set keycolumns command.. This should be followed by the integer number of desired columns, for example:
set keycolumns 2
An example of a plot with a two-column legend is given in Figure 3.4.