Subversion Repositories cheapmusic

Rev

Blame | Last modification | View Log | RSS feed

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>5.15. Example - Stacked Bars, Unshaded</title><link rel="stylesheet" type="text/css" href="phplotdoc.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="PHPlot Reference Manual" /><link rel="up" href="examples.html" title="Chapter 5. PHPlot Examples" /><link rel="prev" href="ex-stackedbars1.html" title="5.14. Example - Stacked Bars, Shaded" /><link rel="next" href="ex-thinbarline1.html" title="5.16. Example - Thin Bar Line Plot" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.15. Example - Stacked Bars, Unshaded</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-stackedbars1.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%" align="right"> <a accesskey="n" href="ex-thinbarline1.html">Next</a></td></tr></table><hr /></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="ex-stackedbars2"></a>5.15. Example - Stacked Bars, Unshaded</h2></div></div></div><p>
This is the same as <a class="xref" href="ex-stackedbars1.html#example-stackedbars1" title="Example 5.14. Stacked Bars, Shaded">Example 5.14, &#8220;Stacked Bars, Shaded&#8221;</a> except we have
turned off shading and now get flat stacked bars with borders.
Also in this example we changed the legend using
<a class="xref" href="SetLegendReverse.html" title="SetLegendReverse"><span class="refentrytitle">SetLegendReverse</span></a> so the lines of text and color boxes
are in the same order as the stacked bar segments, bottom-to-top.
</p><div class="example"><a id="example-stackedbars2"></a><p class="title"><strong>Example 5.15. Stacked Bars, Unshaded</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/stackedbars2.png" alt="Stacked Bars, Unshaded Example" /></div></div><pre class="programlisting">&lt;?php
# PHPlot Example: Stacked Bars, unshaded
require_once 'phplot.php';

$data = array(
  array('Jan', 40, 5, 10, 3), array('Feb', 90, 8, 15, 4),
  array('Mar', 50, 6, 10, 4), array('Apr', 40, 3, 20, 4),
  array('May', 75, 2, 10, 5), array('Jun', 45, 6, 15, 5),
  array('Jul', 40, 5, 20, 6), array('Aug', 35, 6, 12, 6),
  array('Sep', 50, 5, 10, 7), array('Oct', 45, 6, 15, 8),
  array('Nov', 35, 6, 20, 9), array('Dec', 40, 7, 12, 9),
);

$plot = new PHPlot(800, 600);
$plot-&gt;SetImageBorderType('plain');

$plot-&gt;SetPlotType('stackedbars');
$plot-&gt;SetDataType('text-data');
$plot-&gt;SetDataValues($data);

$plot-&gt;SetTitle('Candy Sales by Month and Product');
$plot-&gt;SetYTitle('Millions of Units');

# No shading:
$plot-&gt;SetShading(0);

$plot-&gt;SetLegend(array('Chocolates', 'Mints', 'Hard Candy', 'Sugar-Free'));
# Make legend lines go bottom to top, like the bar segments (PHPlot &gt; 5.4.0)
$plot-&gt;SetLegendReverse(True);

$plot-&gt;SetXTickLabelPos('none');
$plot-&gt;SetXTickPos('none');

$plot-&gt;DrawGraph();
</pre></div></div><br class="example-break" /></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ex-stackedbars1.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="examples.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ex-thinbarline1.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.14. Example - Stacked Bars, Shaded </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.16. Example - Thin Bar Line Plot</td></tr></table></div></body></html>