SetLegendReverse

SetLegendReverse — Control the order of text lines in the legend

Synopsis

$plot->SetLegendReverse($reverse)

Description

SetLegendReverse is used to change the order of entries in the legend. A legend is drawn if SetLegend is used. The legend contains of a series of text strings, and optionally color boxes or point shapes, identifying the data sets (for example, plot lines). The legend line identifying the first data set is normally drawn at the top of the legend, with the rest of the lines in order below it. SetLegendReverse can be used to reverse that order, so the line for the first data set is drawn at the bottom of the legend.

Parameters

$reverse

True to reverse the order of legend entries (bottom up), False to keep the default order (top down).

Notes

The main use of this function is to set the legend line order for stackedbars and stackedarea plots. In these plot types, the first data set (bar segment or area section) is plotted along the the bottom of the plot, with subsequent data sets in order above it. By default, a legend for these plot types will correctly identify the data sets by color, but the entries in the legend will be in the opposite order compared to the data sets and colors on the plot. Use $plot->SetLegendReverse(True) with these plot types to keep the legend entries and plotted data sets in the same order.

See Section 5.15, “Example - Stacked Bars, Unshaded” for an example showing the legend ordering reversal, compared to Section 5.14, “Example - Stacked Bars, Shaded”.

History

This function was added to PHPlot-5.5.0.