5.27. Example - Horizontal Bar Chart

This example shows a horizontal bar chart. As always, the X axis is horizontal, and the Y axis is vertical. But the data array contains the X value for each implicit Y. The data type 'text-data-yx' indicates this is a horizontal plot.

This example also has a tiled background image under the plot area.

Example 5.27. Horizontal Bar Chart

Horizontal Bar Chart Example
# PHPlot Example - Horizontal Bars
require_once 'phplot.php';

$data = array(
  array('San Francisco CA', 20.11),
  array('Reno NV', 7.5),
  array('Phoenix AZ', 8.3),
  array('New York NY', 49.7),
  array('New Orleans LA', 64.2),
  array('Miami FL', 52.3),
  array('Los Angeles CA', 13.2),
  array('Honolulu HI', 18.3),
  array('Helena MT', 11.3),
  array('Duluth MN', 31.0),
  array('Dodge City KS', 22.4),
  array('Denver CO', 15.8),
  array('Burlington VT', 36.1),
  array('Boston MA', 42.5),
  array('Barrow AL', 4.2),

$plot = new PHPlot(800, 800);
$plot->SetImageBorderType('plain'); // Improves presentation in the manual
$plot->SetTitle("Average Annual Precipitation (inches)\n"
              . "Selected U.S. Cities");
#  Set a tiled background image:
$plot->SetPlotAreaBgImage('images/drop.png', 'centeredtile');
#  Force the X axis range to start at 0:
#  No ticks along Y axis, just bar labels:
#  No ticks along X axis:
#  No X axis labels. The data values labels are sufficient.
#  Turn on the data value labels:
#  No grid lines are needed:
#  Set the bar fill color:
#  Use less 3D shading on the bars:

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.