Пример #1
0
<?php

# $Id$
# PHPlot test: Truecolor linepoints, looking at point shapes
require_once 'phplot.php';
# Array of all point shapes as of PHPlot-5.1.0:
$point_shapes = array('halfline', 'line', 'plus', 'cross', 'rect', 'circle', 'dot', 'diamond', 'triangle', 'trianglemid', 'delta', 'yield', 'star', 'hourglass', 'bowtie', 'target', 'box', 'home', 'up', 'down');
$n = count($point_shapes);
$data = array();
for ($x = 0; $x < 4; $x++) {
    $row = array('', $x);
    for ($i = 0; $i < $n; $i++) {
        $row[] = ($i + 1) / 3 * $x;
    }
    $data[] = $row;
}
$p = new PHPlot_truecolor(1000, 800);
$p->SetTitle("Truecolor linespoint plot with all point shapes");
$p->SetDataType('data-data');
$p->SetDataValues($data);
# Reload data colors and apply alpha to all:
$p->SetDataColors(NULL, NULL, 60);
$p->SetLineWidths(3);
$p->SetLineStyles('solid');
$p->SetPointSizes(16);
$p->SetPointShapes($point_shapes);
$p->SetPlotType('linepoints');
$p->DrawGraph();
Пример #2
0
# Make some pseudo-random data.
mt_srand(1);
$data = array();
$value = 10;
for ($i = 0; $i < 500; $i++) {
    $data[] = array('', $i, $value);
    $value = max(0, $value + mt_rand(-9, 10));
}
# Make a color gradient array of blue:
$colors = array();
for ($b = 32; $b <= 255; $b += 2) {
    $colors[] = array(0, 0, $b);
}
for ($b = 255; $b >= 32; $b -= 2) {
    $colors[] = array(0, 0, $b);
}
# Use a truecolor plot image in order to get more colors.
$plot = new PHPlot_truecolor(800, 600);
$plot->SetImageBorderType('plain');
// Improves presentation in the manual
$plot->SetPlotType('thinbarline');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetLineWidths(2);
$plot->SetDataColors($colors);
$plot->SetXTickPos('none');
$plot->SetPlotAreaWorld(0, 0, 500, NULL);
$plot->SetTitle('Meaningless Data with Color Gradient');
# Establish the function 'getcolor' as a data color selection callback.
$plot->SetCallback('data_color', 'getcolor');
$plot->DrawGraph();