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.33. Example - Linepoints Plot with Data Value Labels</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-ohlccandlesticks2.html" title="5.32. Example - Filled Candlesticks OHLC (Open, High, Low, Close) Financial Plot" /><link rel="next" href="ex-outbreak.html" title="5.34. Example - Overlaying Plots" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.33. Example - Linepoints Plot with Data Value Labels</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-ohlccandlesticks2.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%" align="right"> <a accesskey="n" href="ex-outbreak.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-linepoints2"></a>5.33. Example - Linepoints Plot with Data Value Labels</h2></div></div></div><p>This example shows a linepoints plot with data value labels. These aretext strings which show the Y value above each point.(This feature was implemented for lines, points, and linepoints plotsin PHPlot-5.3.0.)Because the Y values are shown with the data value labels, we have chosento turn off the Y axis ticks and tick labels, which would be somewhatredundant.This example also has data label lines(see <a class="xref" href="SetDrawXDataLabelLines.html" title="SetDrawXDataLabelLines"><span class="refentrytitle">SetDrawXDataLabelLines</span></a>),which are the lines drawn from the X axis up to the data points, to helpassociate the point with the X axis label.</p><div class="example"><a id="example-linepoints2"></a><p class="title"><strong>Example 5.33. Linepoints Plot with Data Value Labels</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/linepoints2.png" alt="Linepoints Plot with Data Value Labels Example" /></div></div><pre class="programlisting"><?php# PHPlot Example: Linepoints plot with Data Value Labelsrequire_once 'phplot.php';$data = array(array('1995', 135),array('1996', ''), // Missing data pointarray('1997', ''),array('1998', ''),array('1999', ''),array('2000', 225),array('2001', ''),array('2002', ''),array('2003', 456),array('2004', 420),array('2005', 373),array('2006', 300),array('2007', 255),array('2008', 283),);$plot = new PHPlot(800, 600);$plot->SetImageBorderType('plain'); // Improves presentation in the manual$plot->SetPlotType('linepoints');$plot->SetDataType('text-data');$plot->SetDataValues($data);$plot->SetTitle("US Federal Emergency Food Assistance, 1995 - 2008\n". "(in $ millions)");# Turn on Y data labels:$plot->SetYDataLabelPos('plotin');# Turn on X data label lines (drawn from X axis up to data point):$plot->SetDrawXDataLabelLines(True);# With Y data labels, we don't need Y ticks, Y tick labels, or grid lines.$plot->SetYTickLabelPos('none');$plot->SetYTickPos('none');$plot->SetDrawYGrid(False);# X tick marks are meaningless with this data:$plot->SetXTickPos('none');$plot->SetXTickLabelPos('none');$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-ohlccandlesticks2.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-outbreak.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.32. Example - Filled Candlesticks OHLC (Open, High, Low, Close) Financial Plot </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.34. Example - Overlaying Plots</td></tr></table></div></body></html>