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.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>
|
|
|
3 |
This example shows a linepoints plot with data value labels. These are
|
|
|
4 |
text strings which show the Y value above each point.
|
|
|
5 |
(This feature was implemented for lines, points, and linepoints plots
|
|
|
6 |
in PHPlot-5.3.0.)
|
|
|
7 |
Because the Y values are shown with the data value labels, we have chosen
|
|
|
8 |
to turn off the Y axis ticks and tick labels, which would be somewhat
|
|
|
9 |
redundant.
|
|
|
10 |
This example also has data label lines
|
|
|
11 |
(see <a class="xref" href="SetDrawXDataLabelLines.html" title="SetDrawXDataLabelLines"><span class="refentrytitle">SetDrawXDataLabelLines</span></a>),
|
|
|
12 |
which are the lines drawn from the X axis up to the data points, to help
|
|
|
13 |
associate the point with the X axis label.
|
|
|
14 |
</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
|
|
|
15 |
# PHPlot Example: Linepoints plot with Data Value Labels
|
|
|
16 |
require_once 'phplot.php';
|
|
|
17 |
|
|
|
18 |
$data = array(
|
|
|
19 |
array('1995', 135),
|
|
|
20 |
array('1996', ''), // Missing data point
|
|
|
21 |
array('1997', ''),
|
|
|
22 |
array('1998', ''),
|
|
|
23 |
array('1999', ''),
|
|
|
24 |
array('2000', 225),
|
|
|
25 |
array('2001', ''),
|
|
|
26 |
array('2002', ''),
|
|
|
27 |
array('2003', 456),
|
|
|
28 |
array('2004', 420),
|
|
|
29 |
array('2005', 373),
|
|
|
30 |
array('2006', 300),
|
|
|
31 |
array('2007', 255),
|
|
|
32 |
array('2008', 283),
|
|
|
33 |
);
|
|
|
34 |
|
|
|
35 |
$plot = new PHPlot(800, 600);
|
|
|
36 |
$plot->SetImageBorderType('plain'); // Improves presentation in the manual
|
|
|
37 |
$plot->SetPlotType('linepoints');
|
|
|
38 |
$plot->SetDataType('text-data');
|
|
|
39 |
$plot->SetDataValues($data);
|
|
|
40 |
$plot->SetTitle("US Federal Emergency Food Assistance, 1995 - 2008\n"
|
|
|
41 |
. "(in $ millions)");
|
|
|
42 |
|
|
|
43 |
# Turn on Y data labels:
|
|
|
44 |
$plot->SetYDataLabelPos('plotin');
|
|
|
45 |
|
|
|
46 |
# Turn on X data label lines (drawn from X axis up to data point):
|
|
|
47 |
$plot->SetDrawXDataLabelLines(True);
|
|
|
48 |
|
|
|
49 |
# With Y data labels, we don't need Y ticks, Y tick labels, or grid lines.
|
|
|
50 |
$plot->SetYTickLabelPos('none');
|
|
|
51 |
$plot->SetYTickPos('none');
|
|
|
52 |
$plot->SetDrawYGrid(False);
|
|
|
53 |
# X tick marks are meaningless with this data:
|
|
|
54 |
$plot->SetXTickPos('none');
|
|
|
55 |
$plot->SetXTickLabelPos('none');
|
|
|
56 |
|
|
|
57 |
$plot->DrawGraph();
|
|
|
58 |
</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>
|