5.33. Example - Linepoints Plot with Data Value Labels

This example shows a linepoints plot with data value labels. These are text strings which show the Y value above each point. (This feature was implemented for lines, points, and linepoints plots in PHPlot-5.3.0.) Because the Y values are shown with the data value labels, we have chosen to turn off the Y axis ticks and tick labels, which would be somewhat redundant. This example also has data label lines (see SetDrawXDataLabelLines), which are the lines drawn from the X axis up to the data points, to help associate the point with the X axis label.

Example 5.33. Linepoints Plot with Data Value Labels

Linepoints Plot with Data Value Labels Example
<?php
# PHPlot Example: Linepoints plot with Data Value Labels
require_once 'phplot.php';

$data = array(
  array('1995', 135),
  array('1996', ''), // Missing data point
  array('1997', ''),
  array('1998', ''),
  array('1999', ''),
  array('2000', 225),
  array('2001', ''),
  array('2002', ''),
  array('2003', 456),
  array('2004', 420),
  array('2005', 373),
  array('2006', 300),
  array('2007', 255),
  array('2008', 283),
);

$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain'); // Improves presentation in the manual
$plot->SetPlotType('linepoints');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
$plot->SetTitle("US Federal Emergency Food Assistance, 1995 - 2008\n"
              . "(in $ millions)");

# Turn on Y data labels:
$plot->SetYDataLabelPos('plotin');

# Turn on X data label lines (drawn from X axis up to data point):
$plot->SetDrawXDataLabelLines(True);

# With Y data labels, we don't need Y ticks, Y tick labels, or grid lines.
$plot->SetYTickLabelPos('none');
$plot->SetYTickPos('none');
$plot->SetDrawYGrid(False);
# X tick marks are meaningless with this data:
$plot->SetXTickPos('none');
$plot->SetXTickLabelPos('none');

$plot->DrawGraph();

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.