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>5.7. Example - Line/Point Plot, Point Shapes</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-bars3.html" title="5.6. Example - Bar Chart, Label Options" /><link rel="next" href="ex-pie1.html" title="5.8. Example - Pie Chart, text-data-single" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.7. Example - Line/Point Plot, Point Shapes</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-bars3.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%" align="right"> <a accesskey="n" href="ex-pie1.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-linepoints1"></a>5.7. Example - Line/Point Plot, Point Shapes</h2></div></div></div><p>
3
This is a 'linepoints' plot (Lines/Points) showing all the point shapes
4
available for 'point' and 'linepoints' plots. In this example, we also
5
use a legend to display a text string for each data set, and change the
6
data colors to get a different color for each point shape.
7
Note that the point shape sizes have been increased to 10 in this example,
8
to make them easier to identify.
9
</p><div class="example"><a id="example-linepoints1"></a><p class="title"><strong>Example 5.7. Line/Point Plot, Point Shapes</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/linepoints1.png" alt="Line/Point Plot Example" /></div></div><pre class="programlisting">&lt;?php
10
# PHPlot Example: Line-Point plot showing all the point shapes
11
require_once 'phplot.php';
12
 
13
# This array is used for both the point shapes and legend:
14
$shapes = array('bowtie', 'box', 'circle', 'cross', 'delta',
15
    'diamond', 'dot', 'down', 'halfline', 'home',
16
    'hourglass', 'line', 'plus', 'rect', 'star',
17
    'target', 'triangle', 'trianglemid', 'up', 'yield');
18
 
19
# Number of shapes defines the number of lines to draw:
20
$n_shapes = count($shapes);
21
 
22
# Make offset diagonal lines, one for each shape:
23
$ppl = 6; # Number of points per line.
24
$data = array();
25
for ($i = 0; $i &lt; $ppl; $i++) {
26
    $subdata = array('', $i);
27
    $offset = $n_shapes + $ppl - $i - 2;
28
    for ($j = 0; $j &lt; $n_shapes; $j++) $subdata[] = $offset - $j;
29
    $data[] = $subdata;
30
}
31
 
32
$plot = new PHPlot(800, 600);
33
$plot-&gt;SetImageBorderType('plain');
34
 
35
$plot-&gt;SetPlotType('linepoints');
36
$plot-&gt;SetDataType('data-data');
37
$plot-&gt;SetDataValues($data);
38
 
39
# Main plot title:
40
$plot-&gt;SetTitle('Linepoints Plot - All Point Shapes');
41
 
42
# Increase X range to make room for the legend.
43
$plot-&gt;SetPlotAreaWorld(0, 0, $ppl, $n_shapes + $ppl - 2);
44
# Turn off tick labels and ticks - not used for this plot.
45
$plot-&gt;SetXTickLabelPos('none');
46
$plot-&gt;SetXTickPos('none');
47
$plot-&gt;SetYTickLabelPos('none');
48
$plot-&gt;SetYTickPos('none');
49
 
50
# Need some different colors;
51
$plot-&gt;SetDataColors(array('orange', 'blue', 'maroon', 'red', 'peru',
52
    'cyan', 'black', 'gold', 'purple', 'YellowGreen',
53
    'SkyBlue', 'green', 'SlateBlue', 'navy', 'aquamarine1',
54
    'violet', 'salmon', 'brown', 'pink', 'DimGrey'));
55
 
56
# Show all shapes:
57
$plot-&gt;SetPointShapes($shapes);
58
 
59
# Make the points bigger so we can see them:
60
$plot-&gt;SetPointSizes(10);
61
 
62
# Make the lines all be solid:
63
$plot-&gt;SetLineStyles('solid');
64
 
65
# Also show that as the legend:
66
$plot-&gt;SetLegend($shapes);
67
 
68
# Draw no grids:
69
$plot-&gt;SetDrawXGrid(False);
70
$plot-&gt;SetDrawYGrid(False);
71
 
72
$plot-&gt;DrawGraph();
73
</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-bars3.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-pie1.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.6. Example - Bar Chart, Label Options </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.8. Example - Pie Chart, text-data-single</td></tr></table></div></body></html>