3.4. PHPlot Plot Types

Abstract

This section describes the PHPlot plot types and their individual data type requirements. Plot types determine the overall look of the graphical representation of the data values. To select the plot type, use SetPlotType. The following plot types are available:

Plot TypeDescription
areaFilled areas between lines. Also known as 'cumulative line plot' or 'component line plot'.
barsFilled bars with optional 3-D look, multiple datasets are offset
linepointsLines between points, a marker at each point, optional error bars
linesStraight lines between data points, optional error bars
piePie chart with or without 3-D affects
pointsDraws a marker at each data point, optional error bars
squaredStepped lines
stackedbarsFilled bars with optional 3-D look, multiple data sets are accumulated and the sum is graphed
thinbarlineVertical lines from X axis up. Also known as impulse.

3.4.1. Plot Type: area (Area Plot)

This plot type draws filled areas between lines. This is often called a 'cumulative line plot' or 'component line plot'. Each data set (set of corresponding Y values from each record in the data array) is plotted in order, with the area between each line and the next line is filled solid. The area between the last line and the X axis is also filled. The data must be arranged so the values are (generally) decreasing within each row, because later drawn filled areas will cover previously drawn areas.

This plot type works with data types 'text-data' and 'data-data' (see Section 3.3.1, “Available Data Types”). For 'text-data', the data X values are assumed to be at 0.5+N for N=0,1,2...

The areas are filled with colors as set with SetDataColors.

An example of this plot type can be seen in Example 5.3, “Area Plot”.

3.4.2. Plot Type: bars (Bar Graph)

This plot type draws a bar chart, with filled rectangles centered on the X values. The rectangles can have a 3-D look or be flat with a border. Multiple data-set plots work, with each one producing a set of bars offset from the previous set.

This plot type only works with data type 'text-data' (see Section 3.3.1, “Available Data Types”). The data X values are assumed to be at 0.5+N for N=0,1,2...

If shading is on with SetShading (default is on with value 5 pixels), then the bars have a 3-D look. If shading is off (SetShading(0)), the bars are flat rectangles with borders. The filled rectangle color is set with SetDataColors. The border color (if shading is off) can be set with SetDataBorderColors.

Examples of this plot type can be seen in Example 5.4, “Bar Chart” and Example 5.5, “Bar Chart - Unshaded”.

3.4.3. Plot Type: linepoints (Lines and Points)

This plot type draws a line graph with a markers at each point, thus combining the 'line' and 'point' plot types.

This plot type works with data types 'text-data' and 'data-data' (see Section 3.3.1, “Available Data Types”). It also works with 'data-data-error' for error bars.

Line and marker colors for each line are set with SetDataColors. Marker styles for each line are set with SetPointShapes. Marker sizes for each line are set with SetPointSizes. Line widths for each line are set with SetLineWidths. Line styles (solid or dashed) for each line are set with SetLineStyles.

You can also suppress the line, or the markers, for individual data sets in a graph. This allows you combine points-only, lines-only, and line/points plots. Refer to SetLineStyles and SetPointShapes for details.

For error-bar plots with data type 'data-data-error' only: Error bar colors for each line are set with SetErrorBarColors. Error bar shape (tee or line) is set with SetErrorBarShape. If tee-shaped error bars are used, the width of the upper and lower 'tee' is set with SetErrorBarSize. Error bar line width is set with SetErrorBarLineWidth.

An example of this plot type can be seen in Example 5.7, “Line/Point Plot, Point Shapes”.

3.4.4. Plot Type: lines (Lines Graph)

This plot type simply draws a line from each point to the next.

This plot type works with data types 'text-data' and 'data-data' (see Section 3.3.1, “Available Data Types”). It also works with 'data-data-error' for error bars.

Line colors for each line are set with SetDataColors. Line widths for each line are set with SetLineWidths. Line styles (solid or dashed) for each line are set with SetLineStyles.

For error-bar plots with data type 'data-data-error' only: Error bar colors for each line are set with SetErrorBarColors. Error bar shape (tee or line) is set with SetErrorBarShape. If tee-shaped error bars are used, the width of the upper and lower 'tee' is set with SetErrorBarSize. Error bar line width is set with SetErrorBarLineWidth.

Examples of this plot type can be seen in Example 5.1, “Line Plot” and Example 5.2, “Line Plot: Functions”.

3.4.5. Plot Type: pie (Pie Chart)

This plot type draws pie charts. The pie chart can have a 3-D look or be drawn flat. The first pie segment starts at 0 degrees (East, or 3:00PM) and they go around the pie in a counter-clockwise direction. Each segment is labeled with its percentage.

This plot type works with data types 'text-data', 'data-data', and 'text-data-single' (see Section 3.3.1, “Available Data Types”). Data arrays for pie charts are handled differently than with other plot types, so the data types are described in more detail below.

If shading is on with SetShading (default is on with value 5 pixels), then the pie chart has a 3-D look. If shading is off (SetShading(0)), the pie chart is drawn flat (circular rather than oval). The position of the segment percentage labels is set with SetLabelScalePosition.

Examples of this plot type can be seen in Example 5.8, “Pie Chart, text-data-single” (text-data-single), Example 5.9, “Pie Chart, text-data” (text-data), and Example 5.10, “Pie Chart, flat with options” (unshaded).

3.4.5.1. Pie Chart with data type: 'text-data-single'

The data array for pie charts with 'text-data-single' data type is structured as follows. Each record in the data array represents a pie segment. The record is an array of 2 elements: label and value, but the label is ignored. The value sets the relative size of a pie segment. PHPlot totals up the values and computes the relative size of each segment.

For example:

$data = array(array('', 1), array('',4), array('',5));

This makes a pie chart with 3 segments, with sizes 10%, 40%, and 50%.

3.4.5.2. Pie Chart with data type: 'text-data'

The data array for pie charts with 'text-data' data type is structured as follows. Each record in the data array is an array of a label followed by N data values. The label is ignored. The pie chart will be produced with N segments. The relative weight of the first segment is the sum of the first data values in each record. The relative weight of each subsequent segment is the sum of the corresponding data values in each record.

For example:

$data = array(array('', 10, 10, 20, 10),
              array('', 15, 10, 15, 10));

This results in 4 segments with sizes 25%, 20%, 35%, and 20%.

3.4.5.3. Pie Chart with data type: 'data-data'

The data array for pie charts with 'data-data' data type is structured the same as 'text-data', except that the first two values in each record are ignored (the positions usually used for label and X value). Each element in the data array represents a record. Each record is an array of a label, X value, then N data values. The label and X value are ignored. The pie chart will be produced with N segments. The relative weight of the first segment is the sum of the first data values in each record. The relative weight of each subsequent segment is the sum of the corresponding data values in each record.

For example:

$data = array(array('', 1, 10, 10, 20, 10),
              array('', 2, 15, 10, 15, 10));

This results in 4 segments with sizes 25%, 20%, 35%, and 20%. The empty strings and '1' and '2' are ignored.

3.4.6. Plot Type: points (Styled Dot Plot)

This plot type draws a point marker at each X,Y value.

This plot type works with data types 'text-data' and 'data-data' (see Section 3.3.1, “Available Data Types”). It also works with 'data-data-error' for points with error bars.

Marker colors for each line are set with SetDataColors. Marker styles for each line are set with SetPointShapes. Marker sizes for each line are set with SetPointSizes.

For error-bar plots with data type 'data-data-error' only: Error bar colors for each line are set with SetErrorBarColors. Error bar shape (tee or line) is set with SetErrorBarShape. If tee-shaped error bars are used, the width of the upper and lower 'tee' is set with SetErrorBarSize. Error bar line width is set with SetErrorBarLineWidth.

Examples of this plot type can be seen in Example 5.12, “Points Plot / Scatterplot” (scatterplot), and Example 5.11, “Points Plot with Error Bars” (with error bars).

3.4.7. Plot Type: squared (Step Plot)

This plot type makes stepped lines. For each point, you get a horizontal line from the previous point to the current X, then a vertical line to the current Y.

This plot type works with data types 'text-data' and 'data-data' (see Section 3.3.1, “Available Data Types”). For 'text-data', the data X values are assumed to be at 0.5+N for N=0,1,2...

Line colors per line are set with SetDataColors. Line widths per line are set with SetLineWidths. Line style (solid or dashed) per line are set with SetLineStyles.

An example of this plot type can be seen in Example 5.13, “Squared Plot”.

3.4.8. Plot Type: stackedbars

This plot type draws a bar chart with stacked bars centered on each X value. Each data set value contributes one segment of a stack. That is, the first data set is drawn at the X axis in the first color, then the second data set is drawn stacked above the first in the second color, etc. For this plot type, all Y data values must be greater than or equal to 0. Negative values are not supported.

This plot type only works with data type 'text-data' (see Section 3.3.1, “Available Data Types”). The data X values are assumed to be at 0.5+N for N=0,1,2...

If shading is on with SetShading (default is on with value 5 pixels), then the bars have a 3-D look. If shading is off (SetShading(0)), the bars are flat rectangles with borders. The filled rectangle colors for each stacked segment are set with SetDataColors. The border color (if shading is off) can be set with SetDataBorderColors.

Examples of this plot type can be seen in Example 5.14, “Stacked Bars, Shaded” and Example 5.15, “Stacked Bars, Shaded”.

3.4.9. Plot Type: thinbarline

This plot type draws vertical lines up from the X axis to the Y value at each point. Other implementations call this type of plot 'impulses'. Plotting multiple data sets does not work, because the lines are drawn on top of each other and only one can typically be seen.

This plot type works with data types 'text-data' and 'data-data' (see Section 3.3.1, “Available Data Types”). For 'text-data', the data X values are assumed to be at 0.5+N for N=0,1,2...

Impulse width can be controlled with SetLineWidths.

Examples of this plot type can be seen in Example 5.16, “Thin Bar Line” and Example 5.17, “Thin Bar Line Plot, Wider Lines”.