SetLegendStyle

SetLegendStyle — Control the appearance of the legend

Synopsis

$plot->SetLegendStyle($text_align, [$colorbox_align], [$style])
    

Description

SetLegendStyle controls the appearance of the legend, which is drawn if SetLegend is used. The legend contains of a series of text strings and color boxes, identifying the plot lines. SetLegendStyle sets the alignment of the text strings and color boxes. The color boxes 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.

Parameters

$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. If 'right', the text strings are right-aligned between the legend box edge and the color boxes.

$colorbox_align

Optional string indicating the alignment of the color boxes: 'left', 'right', or 'none'. If 'left', the color boxes are drawn along the left side of the legend box. If 'right', the color boxes are drawn along the right side of the legend box. If 'none', no color boxes are drawn. If this parameter is omitted, the same alignment as $text_align is used.

$style

Optional parameter, reserved for future use, and currently ignored.

Notes

By default, the color boxes are lined up along the right side of the legend box, and the text strings are right-aligned just left of the color boxes. The following figure shows the four possible alignment choices.

Four possible text/color-box 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.

This function was added to PHPlot-5.0.4.