This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/includes/jpgraph/docs/chunkhtml/ch15s03.html

72 lines
9.5 KiB
HTML
Raw Normal View History

2011-05-28 09:51:52 +00:00
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Error plot graphs</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch15.html" title="Chapter 15. Different types of linear (cartesian) graph types"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Error plot graphs</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 15. Different types of linear (cartesian) graph types</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="Error plot graphs"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec1.creating-error-graphs"></a>Error plot graphs</h2></div></div></div>
<p>Error plots are used to visually indicate uncertainty in data points. This is done
by specifying both a min and and max value for each data point.</p>
<p>Before error plots can be used the module "<code class="filename">jpgraph_error.php</code>"
must be included.</p>
<p>The following example illustrates a simple error bar. We will have 5 points, so we
need 10 Y-values. We also would like the error bars to be red and 2 pixels wide. All
this is accomplished by creating an instance of the <code class="code">ErrorPlot</code> class in
much the same way as, for example, a normal line plot.</p>
<p>
</p><div class="figure"><a name="fig.example13"></a><p class="title"><b>Figure 15.58. A basic error plot <code class="uri"><a class="uri" href="example_src/example13.html" target="_top">(<code class="filename">example13.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/example13.png" alt="A basic error plot (example13.php)"></span> </div></div><p><br class="figure-break">
</p>
<p>There is one displeasing esthetic quality of this graph. The X-scale is just wide
enough to just accompany the number of error bars and hence the first bar is drawn
on the Y-axis and the and last bar just at the edge of the plot area. </p>
<p>To adjust this we can use the method <code class="code">ErrorPlot::SetCenter()</code> which
will adjust the x-scale so it does not use the full width of the X-axis.</p>
<p>
</p><div class="figure"><a name="fig.example14"></a><p class="title"><b>Figure 15.59. Making use of SetCenter() with error plots <code class="uri"><a class="uri" href="example_src/example14.html" target="_top">(<code class="filename">example14.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/example14.png" alt="Making use of SetCenter() with error plots (example14.php)"></span> </div></div><p><br class="figure-break">
</p>
<p></p>
<div class="sect2" title="Line error plots"><div class="titlepage"><div><div><h3 class="title"><a name="id2560625"></a>Line error plots</h3></div></div></div>
<p>A variant of the error plot graph is to use an <code class="code">LineErrorPlot</code>
instead. This is almost the same as the <code class="code">ErrorPlot</code> but with the
added feature that each data point also has an middle value which a line is
drawn through. This can be thought of as a line plot combined with an error
plot.</p>
<p>Since this also uses a line the module "<code class="filename">jpgraph_line.ph</code>p"
must be included in addition to the error module.</p>
<p>To control the various properties of the line drawn the "line" property of the
error line plot may be accessed. So, for example, to set the line to have weight
of 2 pixels wide and with a blue color the following two lines are needed</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$elplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">line</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetWeight</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-number">2</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$elplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">line</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColor</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-quotes">'</span><span class="hl-string">blue</span><span class="hl-quotes">'</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p>
<p>An example of this is shown in <a class="xref" href="ch15s03.html#fig.example15" title="Figure 15.60. A basic Line error plot (example15.php)">Figure 15.60. A basic Line error plot <code class="uri"><a class="uri" href="example_src/example15.html" target="_top">(<code class="filename">example15.php</code>)</a></code> </a>. We could
now also add a legend to none, one or both of the line types(the plain line
and/or the error bar). So for example if we wanted the legend "Min/Max" for the
red error bars and a legend "Average" for the blue line the following lines
should be added</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$errplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetLegend</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-quotes">'</span><span class="hl-string">Min/Max</span><span class="hl-quotes">'</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$errplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">line</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetLegend</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-quotes">'</span><span class="hl-string">Average</span><span class="hl-quotes">'</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p>
<p>The result is shown in <a class="xref" href="ch15s03.html#fig.example16" title="Figure 15.61. A line error plot with a legend (example16.php)">Figure 15.61. A line error plot with a legend <code class="uri"><a class="uri" href="example_src/example16.html" target="_top">(<code class="filename">example16.php</code>)</a></code> </a></p>
<p>
</p><div class="informaltable">
<table border="0"><colgroup><col class="c1"><col class="c2"></colgroup><tbody><tr><td>
<div class="figure"><a name="fig.example15"></a><p class="title"><b>Figure 15.60. A basic Line error plot <code class="uri"><a class="uri" href="example_src/example15.html" target="_top">(<code class="filename">example15.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/example15.png" alt="A basic Line error plot (example15.php)"></span> </div></div><br class="figure-break">
</td><td>
<div class="figure"><a name="fig.example16"></a><p class="title"><b>Figure 15.61. A line error plot with a legend <code class="uri"><a class="uri" href="example_src/example16.html" target="_top">(<code class="filename">example16.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/example16.png" alt="A line error plot with a legend (example16.php)"></span> </div></div><br class="figure-break">
</td></tr></tbody></table>
</div><p>
</p>
</div>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="ch15.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>