Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
98 - 1
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
2
<!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.49. Example - Horizontal Error Plot</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-horizlinepts.html" title="5.48. Example - Horizontal Linepoints Plot with Data Value Labels and Lines" /><link rel="next" href="ex-boxplot1.html" title="5.50. Example - Box Plot with Data Reduction" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.49. Example - Horizontal Error Plot</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-horizlinepts.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%" align="right"> <a accesskey="n" href="ex-boxplot1.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-horizerror"></a>5.49. Example - Horizontal Error Plot</h2></div></div></div><p>
3
This is a horizontal error plot, showing a series of measurements as
4
a 'points' plot, with error bars.
5
In a horizontal plot, the Y (vertical) axis is for the independent values,
6
and the X axis (horizontal) is for the dependent values.
7
</p><p>
8
Note: Horizontal error plots were added in PHPlot-6.1.0.
9
</p><div class="example"><a id="example-horizerror"></a><p class="title"><strong>Example 5.49. Horizontal Error Plot</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/horizerror.png" alt="Horizontal Error Plot Example" /></div></div><pre class="programlisting">&lt;?php
10
# PHPlot Example - Horizontal Error Plot
11
require_once 'phplot.php';
12
 
13
# The experimental results as a series of temperature measurements:
14
$results = array(98, 102, 100, 103, 101, 105, 110, 108, 109);
15
# The accuracy of our measuring equipment is +/- 5%
16
$error_factor = 0.05;
17
 
18
# Convert the experimental results to a PHPlot data array for error plots.
19
function reduce_data($results, $error_factor)
20
{
21
    # Use the average of measurements to approximate the error amount:
22
    $err = $error_factor * array_sum($results) / count($results);
23
 
24
    # Build the 'data-data-yx-error' data array:
25
    $data = array();
26
    $i = 1;
27
    foreach ($results as $value) {
28
        $data[] = array("Sample $i", $i++, $value, $err, $err);
29
    }
30
    return $data;
31
}
32
 
33
$plot = new PHPlot(800, 600);
34
$plot-&gt;SetTitle('Experiment Results');
35
$plot-&gt;SetXTitle('Melting Temperature (degrees C)');
36
$plot-&gt;SetDataValues(reduce_data($results, $error_factor));
37
$plot-&gt;SetDataType('data-data-yx-error');
38
$plot-&gt;SetPlotType('points');
39
$plot-&gt;SetYTickPos('none');
40
$plot-&gt;SetImageBorderType('plain'); // Improves presentation in the manual
41
$plot-&gt;SetPlotAreaWorld(80);
42
$plot-&gt;DrawGraph();
43
</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-horizlinepts.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-boxplot1.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.48. Example - Horizontal Linepoints Plot with Data Value Labels and Lines </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.50. Example - Box Plot with Data Reduction</td></tr></table></div></body></html>