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.13. Example - Squared Plot</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-points2.html" title="5.12. Example - Points Plot / Scatterplot" /><link rel="next" href="ex-stackedbars1.html" title="5.14. Example - Stacked Bars, Shaded" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.13. Example - Squared Plot</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-points2.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%" align="right"> <a accesskey="n" href="ex-stackedbars1.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-squared1"></a>5.13. Example - Squared Plot</h2></div></div></div><p>
|
|
|
3 |
This is a squared line plot, which is similar to a line plot but
|
|
|
4 |
the points are connected with steps.
|
|
|
5 |
</p><div class="example"><a id="example-squared1"></a><p class="title"><strong>Example 5.13. Squared Plot</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/squared1.png" alt="Squared Plot Example" /></div></div><pre class="programlisting"><?php
|
|
|
6 |
# PHPlot Example: squared plot
|
|
|
7 |
require_once 'phplot.php';
|
|
|
8 |
|
|
|
9 |
# To get repeatable results with 'random' data:
|
|
|
10 |
mt_srand(1);
|
|
|
11 |
|
|
|
12 |
# Make some noisy data:
|
|
|
13 |
$data = array();
|
|
|
14 |
for ($i = 0; $i < 100; $i++)
|
|
|
15 |
$data[] = array('', $i / 4.0 + 2.0 + mt_rand(-20, 20) / 10.0);
|
|
|
16 |
|
|
|
17 |
$plot = new PHPlot(800, 600);
|
|
|
18 |
$plot->SetImageBorderType('plain');
|
|
|
19 |
|
|
|
20 |
$plot->SetPlotType('squared');
|
|
|
21 |
$plot->SetDataType('text-data');
|
|
|
22 |
$plot->SetDataValues($data);
|
|
|
23 |
|
|
|
24 |
$plot->SetTitle('Noisy Data (squared plot)');
|
|
|
25 |
|
|
|
26 |
# Make the lines a bit wider:
|
|
|
27 |
$plot->SetLineWidths(2);
|
|
|
28 |
|
|
|
29 |
# Turn on the X grid (Y grid is on by default):
|
|
|
30 |
$plot->SetDrawXGrid(True);
|
|
|
31 |
|
|
|
32 |
# Use exactly this data range:
|
|
|
33 |
$plot->SetPlotAreaWorld(0, 0, 100, 40);
|
|
|
34 |
|
|
|
35 |
$plot->DrawGraph();
|
|
|
36 |
</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-points2.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-stackedbars1.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.12. Example - Points Plot / Scatterplot </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.14. Example - Stacked Bars, Shaded</td></tr></table></div></body></html>
|