SetLegendStyle
Prev | PHPlot Function Reference | Next

## SetLegendStyle

SetLegendStyle — Control the appearance of the legend

## Synopsis

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

## 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 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.

## 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 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.

## Notes

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.

## History

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.

Prev | Up | Next
SetLegendReverse | Home | SetLegendTextColor