In the area plot, PHPlot fills the area from each data set down to the next data set, or to the X axis for the last data set. For this example, the data was prepared such that the data sets are cumulative percentages. (See also Example 5.21, “Stacked Area Plot” which produces a similar plot using a different data representation.)
Example 5.3. Area Plot
<?php # PHPlot Example: Area chart, 6 areas. require_once 'phplot.php'; $data = array( array('1960', 100, 70, 60, 54, 16, 2), array('1970', 100, 80, 63, 54, 22, 20), array('1980', 100, 80, 66, 54, 27, 25), array('1990', 100, 95, 69, 54, 28, 10), array('2000', 100, 72, 72, 54, 38, 5), ); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); $plot->SetPlotType('area'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); # Main plot title: $plot->SetTitle('Candy Sales by Flavor'); # Set Y data limits, tick increment, and titles: $plot->SetPlotAreaWorld(NULL, 0, NULL, 100); $plot->SetYTickIncrement(10); $plot->SetYTitle('% of Total'); $plot->SetXTitle('Year'); # Colors are significant to this data: $plot->SetDataColors(array('red', 'green', 'blue', 'yellow', 'cyan', 'magenta')); $plot->SetLegend(array('Cherry', 'Lime', 'Lemon', 'Banana', 'Apple', 'Berry')); # Turn off X tick labels and ticks because they don't apply here: $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->DrawGraph();
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.