SetLegendStyle — Control the appearance of the legend
$plot->SetLegendStyle($text_align
, [$colorbox_align
])
SetLegendStyle
controls the appearance of the legend,
which is drawn if SetLegend is used. The legend
contains of a series of text strings and either color boxes or shape markers,
identifying the plot lines. SetLegendStyle sets the alignment of
the text strings and color boxes or shapes markers. First the color boxes or
shapes markers are aligned within the legend box, left or right, and then the
text strings are aligned within the remaining space, left or right.
SetLegendStyle can also turn off the color boxes or shape markers.
$text_align
A string indicating the alignment of the text strings: 'left' or 'right'. If 'left', the text strings are left-aligned between the legend box edge and the color boxes or shape markers. If 'right', the text strings are right-aligned between the legend box edge and the color boxes or shape markers.
$colorbox_align
Optional string indicating the alignment of the color boxes or shape markers: 'left', 'right', or 'none'. If 'left', they are drawn along the left side of the legend box. If 'right', they are drawn along the right side of the legend box. If 'none', no color boxes or shape markers are drawn. If this parameter is omitted, the same alignment as $text_align is used.
By default, the color boxes or shape markers are lined up along the right side of the legend box, and the text strings are right-aligned just left of the color boxes or shape markers. The following figure shows the four possible alignment choices.
Using 'none' for $colorbox_align results in a legend with only text lines. This is not recommended for multi-line or multi-dataset plots, unless you have provided some other way to indicate which legend text line goes with which plot, or if you are using the legend for some purpose other than identifying the plot lines.
In PHPlot-6.0, the term 'point shapes' was replaced with 'shape markers',
since PHPlot can now produce markers for line plots as well. (There was no
change to the behavior of SetLegendStyle
- only the
description changed.)
The option to use point shapes instead of color boxes in the legend
was added in PHPlot-5.4.0. See SetLegendUseShapes.
In earlier releases, the $colorbox_align
parameter to
SetLegendStyle
only applied to color boxes.
Through PHPlot-5.3.1, there was an optional third parameter
$style
, which was intended for possible future use
but was never used. It was removed at PHPlot-5.4.0.
This function was added to PHPlot-5.0.4.
This version of the manual was produced for the
PHPlot Sourceforge project web service site, which requires the logo on each
page.
To download a logo-free copy of the manual, see the
PHPlot project downloads
area.