Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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>Chapter 5. PHPlot Examples</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="part1.html" title="Part I. PHPlot Programming" /><link rel="prev" href="adv-imgmap.html" title="4.10. Image Maps for Plot Data" /><link rel="next" href="ex-lines2.html" title="5.2. Example - Line Plot: Functions" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. PHPlot Examples</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="adv-imgmap.html">Prev</a> </td><th width="60%" align="center">Part I. PHPlot Programming</th><td width="20%" align="right"> <a accesskey="n" href="ex-lines2.html">Next</a></td></tr></table><hr /></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="examples"></a>Chapter 5. PHPlot Examples</h2></div></div></div><div class="abstract"><p class="title"><strong></strong></p><p>
3
This chapter contains examples of plots produced with PHPlot.
4
  </p></div><p>
5
Each of the following PHPlot examples shows an image, followed by the PHP
6
script which produced that image.  Each script is self-contained (needing
7
only PHPlot), so you can copy it from this manual and run it with PHP to
8
produce the image.
9
Note that some of the scripts may require the latest version of PHPlot.
10
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
11
The PHP CLI (command line interface), used to generate the examples here,
12
never outputs HTTP headers. So it isn't necessary to use
13
<a class="xref" href="SetIsInline.html" title="SetIsInline"><span class="refentrytitle">SetIsInline</span></a> to suppress headers when using the CLI.
14
This is a useful method you can use to debug and test your own PHPlot scripts
15
without having to modify them for stand-alone use.
16
Also, by using the CLI instead of a web server and browser, you can more
17
readily see any error messages.
18
Run your PHPlot scripts with the PHP CLI like this (using the
19
<a class="ulink" href="http://www.imagemagick.org/" target="_top">ImageMagick</a>
20
display program to view the results):
21
    </p><pre class="screen">$  php myscript.php &gt; output.png
22
$  display output.png
23
</pre><p>
24
  </p><p>
25
<span class="application">ImageMagick</span> is available for several operating systems.
26
There are many other image viewers for Linux and Linux-like systems,
27
including <span class="application">qiv</span> and <span class="application">geeqie</span>.
28
  </p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="ex-lines1"></a>5.1. Example - Line Plot</h2></div></div></div><p>
29
This is a simple line plot with a single data set. Data type 'data-data'
30
is used to include the X values (the years) in the data points.
31
</p><div class="example"><a id="example-lines1"></a><p class="title"><strong>Example 5.1. Line Plot</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/lines1.png" alt="Line Plot Example" /></div></div><pre class="programlisting">&lt;?php
32
# PHPlot Example: Simple line graph
33
require_once 'phplot.php';
34
 
35
$data = array(
36
  array('', 1800,   5), array('', 1810,   7), array('', 1820,  10),
37
  array('', 1830,  13), array('', 1840,  17), array('', 1850,  23),
38
  array('', 1860,  31), array('', 1870,  39), array('', 1880,  50),
39
  array('', 1890,  63), array('', 1900,  76), array('', 1910,  92),
40
  array('', 1920, 106), array('', 1930, 123), array('', 1940, 132),
41
  array('', 1950, 151), array('', 1960, 179), array('', 1970, 203),
42
  array('', 1980, 227), array('', 1990, 249), array('', 2000, 281),
43
);
44
 
45
$plot = new PHPlot(800, 600);
46
$plot-&gt;SetImageBorderType('plain');
47
 
48
$plot-&gt;SetPlotType('lines');
49
$plot-&gt;SetDataType('data-data');
50
$plot-&gt;SetDataValues($data);
51
 
52
# Main plot title:
53
$plot-&gt;SetTitle('US Population, in millions');
54
 
55
# Make sure Y axis starts at 0:
56
$plot-&gt;SetPlotAreaWorld(NULL, 0, NULL, NULL);
57
 
58
$plot-&gt;DrawGraph();
59
</pre></div></div><br class="example-break" /></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="adv-imgmap.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="part1.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ex-lines2.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.10. Image Maps for Plot Data </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.2. Example - Line Plot: Functions</td></tr></table></div></body></html>