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.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>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>).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 arrayis already processed, and includes the 5 values that make up each row for abox plot (<code class="literal">Ymin, YQ1, Ymid, YQ3, Ymax</code>) and someadditional <span class="emphasis"><em>outlier</em></span> points.This example also shows how colors and line styles can be applied to a boxplot.</p><p>Note: Box plots were added in PHPlot-6.1.0.</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# PHPlot Example - Box Plot with outliers and line stylesrequire_once 'phplot.php';# Data array: each row is (label, X, Ymin, YQ1, Ymid, YQ3, Ymax, [Youtlier...])$data = array(array('', 1, 10, 15, 20, 25, 30),array('', 2, 12, 14, 18, 20, 24, 6, 8, 28),array('', 3, 5, 11, 19, 28, 35),array('', 4, 14, 17, 21, 26, 28, 9, 12, 35, 32),array('', 5, 12, 15, 22, 27, 30),array('', 6, 15, 18, 20, 22, 26, 12),array('', 7, 10, 15, 21, 26, 28, 32),array('', 8, 11, 15, 20, 24, 27, 6, 8),array('', 9, 10, 15, 19, 22, 26, 4, 34),);$plot = new PHPlot(800, 600);$plot->SetTitle('Box Plot with outliers and styles');$plot->SetDataType('data-data');$plot->SetDataValues($data);$plot->SetPlotType('boxes');$plot->SetImageBorderType('plain'); // Improves presentation in the manual# Use dashed lines for the upper and lower whiskers:$plot->SetLineStyles('dashed');# Make the box and belt use a thicker line:$plot->SetLineWidths(array(3, 3, 1));# Make the outliers red, and everything else blue:$plot->SetDataColors(array('blue', 'blue', 'red', 'blue'));# Draw the outliers using a "star":$plot->SetPointShapes('star');$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-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>