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.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-hori
zlinepts.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>
This is a horizontal error plot, showing a series of measurements as
a 'points' plot, with error bars.
In a horizontal plot, the Y (vertical) axis is for the independent values,
and the X axis (horizontal) is for the dependent values.
</p><p>
Note: Horizontal error plots were added in PHPlot-6.1.0.
</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"><?php
# PHPlot Example - Horizontal Error Plot
require_once 'phplot.php';
# The experimental results as a series of temperature measurements:
$results = array(98, 102, 100, 103, 101, 105, 110, 108, 109);
# The accuracy of our measuring equipment is +/- 5%
$error_factor = 0.05;
# Convert the experimental results to a PHPlot data array for error plots.
function reduce_data($results, $error_factor)
{
# Use the average of measurements to approximate the error amount:
$err = $error_factor * array_sum($results) / count($results);
# Build the 'data-data-yx-error' data array:
$data = array();
$i = 1;
foreach ($results as $value) {
$data[] = array("Sample $i", $i++, $value, $err, $err);
}
return $data;
}
$plot = new PHPlot(800, 600);
$plot->SetTitle('Experiment Results');
$plot->SetXTitle('Melting Temperature (degrees C)');
$plot->SetDataValues(reduce_data($results, $error_factor));
$plot->SetDataType('data-data-yx-error');
$plot->SetPlotType('points');
$plot->SetYTickPos('none');
$plot->SetImageBorderType('plain'); // Improves presentation in the manual
$plot->SetPlotAreaWorld(80);
$plot->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-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>