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.51. Example - Box Plot with Outliers and Styles</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-boxplot1.html" title="5.50. Example - Box Plot with Data Reduction" /><link rel="next" href="ex-squaredarea1.html" title="5.52. Example - Squared Area Plot" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.51. Example - Box Plot with Outliers and Styles</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-boxplot1.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%" align="right"> <a accesskey="n" href="ex-squaredarea1.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-boxplot2"></a>5.51. Example - Box Plot with Outliers and Styles</h2></div></div></div><p>
|
|
|
3 |
This is a box plot (plot type <a class="link" href="conc-plottypes.html#plottype-boxes" title="3.4.3. Plot Type: boxes (Box Plot)">boxes</a>).
|
|
|
4 |
Unlike the previous example (<a class="xref" href="ex-boxplot1.html" title="5.50. Example - Box Plot with Data Reduction">Section 5.50, “Example - Box Plot with Data Reduction”</a>) the data array
|
|
|
5 |
is already processed, and includes the 5 values that make up each row for a
|
|
|
6 |
box plot (<code class="literal">Ymin, YQ1, Ymid, YQ3, Ymax</code>) and some
|
|
|
7 |
additional <span class="emphasis"><em>outlier</em></span> points.
|
|
|
8 |
This example also shows how colors and line styles can be applied to a box
|
|
|
9 |
plot.
|
|
|
10 |
</p><p>
|
|
|
11 |
Note: Box plots were added in PHPlot-6.1.0.
|
|
|
12 |
</p><div class="example"><a id="example-boxplot2"></a><p class="title"><strong>Example 5.51. Box Plot with Outliers and Styles</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/boxplot2.png" alt="Box Plot with Outliers and Styles" /></div></div><pre class="programlisting"><?php
|
|
|
13 |
# PHPlot Example - Box Plot with outliers and line styles
|
|
|
14 |
require_once 'phplot.php';
|
|
|
15 |
|
|
|
16 |
# Data array: each row is (label, X, Ymin, YQ1, Ymid, YQ3, Ymax, [Youtlier...])
|
|
|
17 |
$data = array(
|
|
|
18 |
array('', 1, 10, 15, 20, 25, 30),
|
|
|
19 |
array('', 2, 12, 14, 18, 20, 24, 6, 8, 28),
|
|
|
20 |
array('', 3, 5, 11, 19, 28, 35),
|
|
|
21 |
array('', 4, 14, 17, 21, 26, 28, 9, 12, 35, 32),
|
|
|
22 |
array('', 5, 12, 15, 22, 27, 30),
|
|
|
23 |
array('', 6, 15, 18, 20, 22, 26, 12),
|
|
|
24 |
array('', 7, 10, 15, 21, 26, 28, 32),
|
|
|
25 |
array('', 8, 11, 15, 20, 24, 27, 6, 8),
|
|
|
26 |
array('', 9, 10, 15, 19, 22, 26, 4, 34),
|
|
|
27 |
);
|
|
|
28 |
|
|
|
29 |
$plot = new PHPlot(800, 600);
|
|
|
30 |
$plot->SetTitle('Box Plot with outliers and styles');
|
|
|
31 |
$plot->SetDataType('data-data');
|
|
|
32 |
$plot->SetDataValues($data);
|
|
|
33 |
$plot->SetPlotType('boxes');
|
|
|
34 |
$plot->SetImageBorderType('plain'); // Improves presentation in the manual
|
|
|
35 |
|
|
|
36 |
# Use dashed lines for the upper and lower whiskers:
|
|
|
37 |
$plot->SetLineStyles('dashed');
|
|
|
38 |
# Make the box and belt use a thicker line:
|
|
|
39 |
$plot->SetLineWidths(array(3, 3, 1));
|
|
|
40 |
# Make the outliers red, and everything else blue:
|
|
|
41 |
$plot->SetDataColors(array('blue', 'blue', 'red', 'blue'));
|
|
|
42 |
# Draw the outliers using a "star":
|
|
|
43 |
$plot->SetPointShapes('star');
|
|
|
44 |
|
|
|
45 |
$plot->DrawGraph();
|
|
|
46 |
</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-boxplot1.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-squaredarea1.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.50. Example - Box Plot with Data Reduction </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.52. Example - Squared Area Plot</td></tr></table></div></body></html>
|