SetXDataLabelPos

SetXDataLabelPos — Position and control X data labels

Synopsis

$plot->SetXDataLabelPos($xdlp)

Description

SetXDataLabelPos determines if and where X data labels are drawn. For vertical plots, these are X axis data labels, which display the label strings from your data array. The labels can be drawn at the bottom of the plot (below the X axis), above the plot, in both positions, or neither. For horizontal plots, these are X data value labels, displaying the value of the data point within the plot area.

Parameters

$xdlp

A string indicating the desired position for the X data labels:

PositionDescription
plotdownData labels below the plot. This is for vertical plots.
plotupData labels above the plot. This is for vertical plots.
bothData labels both below and above the plot. This is for vertical plots.
plotinData value labels within the plot area. For bar charts, this displays the value to the right (or left) of each bar. For stacked bar charts, this display only the bar total labels and not the bar segment labels. For other plot types, see notes below.
plotstackData value labels to the right (or left) of each bar, and just left of the end of each bar segment. This is valid for horizontal stacked bar plots only. It turns on both bar total labels (as with 'plotin') and bar segment labels.
noneNo data labels or data value labels

Notes

With vertical plots, this function controls the X axis data labels. For an example, see Section 5.3, “Example - Area Plot”, where the labels are enabled by default and displayed below the X axis. With horizontal plots, this function controls the X data value labels. For examples, see Example 5.27, “Horizontal Bar Chart” and Example 5.28, “Horizontal Stacked Bar Chart”.

The default position for X data labels (for vertical plots) is below the plot. However, PHPlot only enables the data labels if SetXDataLabelPos was used to position them, or if SetXTickLabelPos was not used to enable the tick labels and the data labels are not all empty.

The default position for X data value labels (for horizontal plots) is 'none', meaning no labels. For plot types 'bars' and 'stackedbars', X data value labels are drawn (if enabled) at fixed positions within or left/right of the bars. For plot types 'lines', 'points', and 'linepoints', X data labels are drawn (if enabled) above the data points by default. The position can be changed (see Section 4.7.7, “Tuning Labels”), but PHPlot does not attempt to prevent interference between the labels and other plot elements. X data value labels are not available with other plot types.

For tick labels, see SetXTickLabelPos.

The bar segment labels, if enabled ('plotstack'), are drawn inside the bars and may not be very visible if dark colors are used for the bar fill. Bar segment labels will be omitted for segments which are too short.

X data value labels will be drawn to the left of the bars for negative values. This only applies to horizontal bar charts. Stacked bar charts are not allowed to have negative values.

If X data label lines are enabled with SetDrawXDataLabelLines, then SetXDataLabelPos() also determines the direction of the lines which are drawn from the data points.

The X data label text angle is set with SetXDataLabelAngle. The X data label text format can be controlled with SetXDataLabelType or SetXLabelType.

X data value labels do work with horizontal error plots (plot types 'lines', 'points', and 'linepoints' and data type data-data-yx-error). The labels will identify the base X values of the points. You can change the default label positions (offset and angle) as explained in Section 4.7.7, “Tuning Labels”).

History

Horizontal error plots, with data labels, were first available in PHPlot-6.1.0.

Horizontal lines, points, and linepoints plots and data value labels for them were first available in PHPlot-6.0.0.

Horizontal bar plot data value labels were added in PHPlot-5.1.3. Through PHPlot-5.1.2, the 'plotin' and 'plotstack' values were not available.

Through PHPlot-5.0.7, the default position for X data labels was below the plot ('plotdown'). This would result in overlaid data and tick labels by default. In addition, positioning the X tick labels with SetXTickLabelPos with a position other than 'none' resulted in disabling the X data labels, and vice-versa. If both tick and data labels were positioned, the later setting overrode the earlier, which was turned off. Starting with PHPlot-5.1.0, PHPlot handles tick and data label positions as described in the notes above.

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.