Subversion Repositories cheapmusic

Rev

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.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>
This is a 'linepoints' plot (Lines/Points) showing all the point shapes
available for 'point' and 'linepoints' plots. In this example, we also
use a legend to display a text string for each data set, and change the
data colors to get a different color for each point shape.
Note that the point shape sizes have been increased to 10 in this example,
to make them easier to identify.
</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
# PHPlot Example: Line-Point plot showing all the point shapes
require_once 'phplot.php';

# This array is used for both the point shapes and legend:
$shapes = array('bowtie', 'box', 'circle', 'cross', 'delta',
    'diamond', 'dot', 'down', 'halfline', 'home',
    'hourglass', 'line', 'plus', 'rect', 'star',
    'target', 'triangle', 'trianglemid', 'up', 'yield');

# Number of shapes defines the number of lines to draw:
$n_shapes = count($shapes);

# Make offset diagonal lines, one for each shape:
$ppl = 6; # Number of points per line.
$data = array();
for ($i = 0; $i &lt; $ppl; $i++) {
    $subdata = array('', $i);
    $offset = $n_shapes + $ppl - $i - 2;
    for ($j = 0; $j &lt; $n_shapes; $j++) $subdata[] = $offset - $j;
    $data[] = $subdata;
}

$plot = new PHPlot(800, 600);
$plot-&gt;SetImageBorderType('plain');

$plot-&gt;SetPlotType('linepoints');
$plot-&gt;SetDataType('data-data');
$plot-&gt;SetDataValues($data);

# Main plot title:
$plot-&gt;SetTitle('Linepoints Plot - All Point Shapes');

# Increase X range to make room for the legend.
$plot-&gt;SetPlotAreaWorld(0, 0, $ppl, $n_shapes + $ppl - 2);
# Turn off tick labels and ticks - not used for this plot.
$plot-&gt;SetXTickLabelPos('none');
$plot-&gt;SetXTickPos('none');
$plot-&gt;SetYTickLabelPos('none');
$plot-&gt;SetYTickPos('none');

# Need some different colors;
$plot-&gt;SetDataColors(array('orange', 'blue', 'maroon', 'red', 'peru',
    'cyan', 'black', 'gold', 'purple', 'YellowGreen',
    'SkyBlue', 'green', 'SlateBlue', 'navy', 'aquamarine1',
    'violet', 'salmon', 'brown', 'pink', 'DimGrey'));

# Show all shapes:
$plot-&gt;SetPointShapes($shapes);

# Make the points bigger so we can see them:
$plot-&gt;SetPointSizes(10);

# Make the lines all be solid:
$plot-&gt;SetLineStyles('solid');

# Also show that as the legend:
$plot-&gt;SetLegend($shapes);

# Draw no grids:
$plot-&gt;SetDrawXGrid(False);
$plot-&gt;SetDrawYGrid(False);

$plot-&gt;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-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>