This section contains information about other elements which can be part of a plot.
PHPlot can draw three types of titles:
The main plot title, which is centered at the top of the image. This is typically used to identify the plot as a whole.
The X title, which is drawn horizontally and can appear below the plot, above the plot, or in both places. This is typically used to identify the values along the X axis.
The Y title, which is drawn vertically and can appear to the left of the plot, to the right of the plot, or on both sides. This is typically used to identify the values along the Y axis.
For a list of functions used to control titles, see Section 6.7, “Titles”.
Here is a sample plot with the titles called out.
PHPlot can draw a legend on the plot. This is normally used with multiple data sets, to identify the data sets by color. A legend can also be used with pie charts to identify the sections. For a list of functions used to control the legend, see Section 6.8, “Legend”.
Use SetLegend to enable the legend and define the text lines to be displayed.
You can let PHPlot position the legend, or position it yourself with SetLegendPixels, SetLegendWorld, or SetLegendPosition.
You can use SetLegendStyle, SetLegendUseShapes, and SetLegendReverse to change the appearance of the legend.
Here is a sample plot with the legend called out.
PHPlot can draw horizontal (Y) and/or vertical (X) grid lines on a plot. You can independently enable the horizontal (Y) and vertical (X) lines in the grid, and use dashed or solid lines. For a list of functions used to control the grid, see Section 6.10, “Grid Controls”.
Here is a sample plot with the X Grid and Y Grid called out.
Tick marks are drawn by default along the bottom edge of the plot (X tick marks) and the left side of the plot (Y tick marks). These usually, but not always, correspond to the X and Y axis lines. You can set the tick interval or control the number of ticks, suppress the first or last tick on an axis, and control the tick mark size. You can also anchor the tick marks at a specific X or Y value. For a list of functions used to control tick marks, see Section 6.12, “Ticks”.
Left to its own, PHPlot will determine tick positions for X and Y axes, but it isn't too smart about choosing the values, and you might not be happy with the results. You can improve the situation with some combination of: setting the desired tick interval, setting a tick anchor point, or using SetPlotAreaWorld to set the X or Y data range limits (since the automatic calculation of tick marks is based on the data range).
For example:
$plot->SetPlotAreaWorld(-10, NULL, 10, NULL); $plot->SetXTickIncrement(1);
This results in the X tick labels going from -10 to 10, with a tick mark every 1 data unit.