SetLegendUseShapes

SetLegendUseShapes — Use color boxes or shape markers in the legend

Synopsis

$plot->SetLegendUseShapes($use_shapes)

Description

SetLegendUseShapes sets the legend to use either color boxes or shapes marker to show which legend line goes with which data set.

Parameters

$use_shapes

A boolean value: true to use shape markers, false to use color boxes.

Notes

By default, the legend is drawn with color boxes.

Use of SetLegendUseShapes(True) instructs PHPlot to use an alternate marker in the legend. The marker depends on the plot type used in the plot.

  • For points and linepoints plots, the alternate marker is the point shape used to identify the data set in the plot.

  • For lines and squared plots, the alternate marker is a short horizontal line segment matching the corresponding data set line in the plot.

  • For all other plot types, no alternate marker is defined, and SetLegendUseShapes is ignored.

When shape markers are enabled using SetLegendUseShapes(True), PHPlot will first draw a solid box with the same color as the plot area background (if plot area background color is enabled with SetPlotBgColor and SetDrawPlotAreaBackground). Then it will draw the shape marker, overlaying the background box.

Point shape markers will have the same color and size as the point shape used in the plot for the corresponding data set. Note that PHPlot will not adjust the legend box size or line spacing based on the point shape sizes set with SetPointSizes. If the point shapes are too big, they will overflow their allocated space and overlap. You can control the legend text line height to account for large point shapes by adjusting the line spacing parameter (using SetLineSpacing, SetFont, or related font control functions.

Line segment markers will have the same color, line width, and style as the lines used in the corresponding data set. The area reserved in the legend for color boxes or shape markers is automatically made 4 times wider when line segment markers are used, in order to improve visibility.

For examples of legends with color boxes and shape markers, see Section 5.35, “Example - Legend with Shape Markers”.

History

PHPlot-6.0.0 added a third type of shape marker for legends: line segments, and SetLegendUseShapes now applies to more plot types. Before PHPlot-6.0.0, only color boxes and point shape markers were available, and SetLegendUseShapes was ignored with plot types other than points and linepoints.

This function was added to PHPlot-5.4.0. Before that, only color boxes were available in legends.

SourceForge.net Logo

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.