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 point
shapes, identifying the plot lines. SetLegendStyle sets the alignment of
the text strings and color boxes or point shapes. First the color boxes or
point shapes 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 point shapes.
$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 point shapes. If 'right', the text strings are right-aligned between the legend box edge and the color boxes or point shapes.
$colorbox_align
Optional string indicating the alignment of the color boxes or point shapes: '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 point shapes are drawn. If this parameter is omitted, the same alignment as $text_align is used.
By default, the color boxes or point shapes 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 point shapes 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.
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.