When a graph has more than one plot, Multigraph automatically adds a legend
in the upper right corner. The legend tag allows you
to control the legend's appearance. The legend tag appears at the top
level inside the mugl tag, and accepts the followng attributes:
visibleThis attribute determines whether the legend is present or not; a value of "true" means that the legend should appear, and "false" means that it should not. The default is for the legend to appear if the graph contains more than one plot. You can use this attribute to disable the legend in graphs containing more than one plot, or to enable it in graphs containing only one plot.
anchorbaseposition
These attributes give the location of the legend relative to the plot area, according
to the conventions described in the section called “Positioning”. If you think of the
legend as being bounded by an imaginary rectangular box, these attributes determine the
location of that box.
base is the location of the base point relative to the plot area;
the default value for base is "1 1" --- i.e. the upper right corner of the plot area.
The default for anchor is also "1 1", which means that the upper right
corner of the legend is anchored to the base point.
position is a coordinate pair of pixel offsets, as described in
the section called “Positioning”; its default value is "0 0".
frame
The frame attribute determines whether the legend is positioned
relative to the plot area or the padding box (described in the section called “Borders, Margins, and the Plot Area”).
More precisely, it determines the coordinate system of the base point,
described above.
The default value is "plot", which means that the legend will be positioned relative
to the plot area. This is usually what you want, since the plot area is where the data
is plotted. If you have a graph that has large margins, however, for example to allow
for multiple vertical axes, you can specify "padding" for the frame
attribute, in which case the legend will be positioned relative
to the padding box (which is the entire window minus any border and padding amount).
rowscolumns
The legend contains an entry for each plot, layed out in a grid.
The rows and columns attributes
determine the number of rows and columns in that grid. If you specify
one of these values and not the other, the other will be determined by
the number of entries in the legend. The default is columns="1"
and rows unspecified, which means that the legend
will be layed out in a single vertical column, with one row per entry. If you
want a single horizontal legend layout instead, specify
rows="1" and leave columns unspecified.
borderThe thickness of the border drawn around the legend; the default is "1". Use "0" to turn off the border.
bordercolorThe color of the border; the default is "0x000000", which is black.
colorThe color used to fill the background of the legend; the default is "0xFFFFFF", or white.
opacityThe opacity value for the legend, in the range 0.0 to 1.0. This is relevant because depending on where the legend is, it may obscure some parts of the plot data. The default is 1.0, which is completely opaque, which means that any parts of the plot data that appear behind the legend will not be visible at all. any
cornerradius
Determines whether the corners of the legend box, if it is drawn, appear rounded.
If cornerradius is 0, which is the default, the corners are drawn square.
If cornerradius > 0, then the corners are rounded off
using circles whose radius is cornerradius pixels.
paddingAn amount of padding, in pixels, to leave between the edges of the legend box and the entries inside it. The default is 0.
The legend tag can optionally contain an
icon subtag, which affects the appearance of the individual plot icons
in the legend. The icon subtag takes the following attributes:
widthheight
The width and height, in pixels, of the icons. The defaults are
width="40" and height="30".
borderThe thickness of a border drawn around the icons; the default is "1". Use "0" to turn off the icon borders.
In addition to the legend tag at the top level
of the mugl file, which controls the overall properties of the legend,
each plot can contain its own legend inside its
plot section for controlling how that plot's entry
in the legend appears. In this context, the legend
tag takes the following attributes:
visible
Determines whether the plot is listed in the legend at all. The default
behavior is for all plots to have an entry in the legend if the legend is present at
all. To omit a particular plot from the legend, specify
visible="false" in that plot's legend tag.
labelThe text to be used for the plot's entry in the legend. The default is to use the id of the (first) variable assigned to the plot's vertical axis.
The individual plot entries in the legend are layed out in the order in which
the corresponding
plot sections appear in the mugl file. To change the order
of the entries in the legend, change the order of the plot
sections.
Below is an example mugl snippet with 4 plots that specifies a legend to be layed out in a single row, centered at the top of the plot area, with no border drawn around either the legend itself or the individual plot icons. One of the plots is omitted from the legend, so the legend will contain 3 columns.
Example 5. Example Legend Specification
<?xml version="1.0"?>
<mugl>
<legend rows="1" base="0 1" anchor="0 1" border="0">
<icon border="0"/>
</legend>
...
<plot>
<legend label="Temperature"/>
...
</plot>
<plot>
<legend label="Precipitation"/>
...
</plot>
<plot>
<legend label="Pressure"/>
...
</plot>
<plot>
<legend visible="false"/>
...
</plot>
...
</mugl>