3.7. Other Plot Elements

This section contains information about other elements which can be part of a plot.

3.7.1. Titles

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.

Titles on a plot

3.7.2. Legend

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 segments. For a list of functions used to control the legend, see Section 6.8, “Legend”.

Here is a sample plot with the legend called out.

Legend on a plot

3.7.3. Grid Lines

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.

X and Y Grid

3.7.4. Tick Marks

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. (See Section 4.6.7, “Automatic Tick Increment Calculation” if you want to read all the details on how PHPlot does this.) Starting with PHPlot-6.0.0, an attempt is made to pick a good tick increment. (Older releases are much less likely to come up with a good result.) Even so, 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.

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.