function draw_graph($example_data, $attribute) { require_once 'phplot.php'; $plot = new PHPlot_truecolor(800, 800); $plot->SetTitle('Distribution of ' . $attribute); $plot->SetImageBorderType('plain'); // Improves presentation in the manual $plot->SetDataValues($example_data); $plot->SetPlotType('linepoints'); $plot->SetDrawYDataLabelLines(True); $plot->SetXTitle("Selected Dates"); $plot->SetYTitle($attribute); $plot->DrawGraph(); }
$shading = 0; } // Shading, empty string to omit if (!isset($alpha)) { $alpha = 50; } // Default data colors alpha, NULL to skip require_once 'phplot.php'; $data = array(); for ($i = 0; $i < 16; $i++) { $data[] = array('', 1); } $p = new PHPlot_truecolor(800, 800); if ($shading === '') { $d_shading = "default shading"; } elseif ($shading === 0) { $d_shading = "no shading"; } else { $d_shading = "shading={$shading}"; } $p->SetTitle("Truecolor Piechart with alpha={$alpha}, {$d_shading}"); $p->SetDataType('text-data-single'); $p->SetDataValues($data); if (isset($alpha)) { $p->SetDataColors(NULL, NULL, $alpha); } $p->SetPlotType('pie'); if ($shading !== '') { $p->SetShading($shading); } $p->DrawGraph();
// Shading, empty string to omit if (!isset($alpha)) { $alpha = 50; } // Default data colors alpha, NULL to skip if (!isset($plottype)) { $plottype = 'bars'; } // bars or stackedbars require_once 'phplot.php'; $data = array(array('Spring', 10, 20, 40, 45, 60), array('Summer', 15, 22, 40, 55, 80), array('Fall', 20, 24, 47, 65, 83), array('Winter', 20, 24, 47, 65, 83)); $p = new PHPlot_truecolor(800, 800); if ($shading === '') { $d_shading = "default shading"; } elseif ($shading === 0) { $d_shading = "no shading"; } else { $d_shading = "shading={$shading}"; } $p->SetTitle("Truecolor {$plottype} chart with alpha={$alpha}, {$d_shading}"); $p->SetDataType('text-data'); $p->SetDataValues($data); if (isset($alpha)) { $p->SetDataColors(NULL, NULL, $alpha); } $p->SetPlotType($plottype); if ($shading !== '') { $p->SetShading($shading); } $p->SetXTickPos('none'); $p->DrawGraph();
<?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();
<?php # $Id$ # PHPlot test - transparency - truecolor, set transparent then set background require_once 'phplot.php'; $data = array(array('A', 6), array('B', 4), array('C', 2), array('D', 0)); $p = new PHPlot_truecolor(); $p->SetTitle('Truecolor, Set transparent, Set background color'); $p->SetDataValues($data); $p->SetPlotType('bars'); $p->SetTitleColor('green'); // For contrast vs black/clear background $p->SetTransparentColor('yellow'); $p->SetBackgroundColor('yellow'); $p->DrawGraph();
# 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();
<?php # $Id$ # PHPlot test: Truecolor stacked area plot require_once 'phplot.php'; $data = array(array('A', 2, 3, 1, 3, 2, 1), array('B', 4, 1, 5, 0, 4, 2), array('C', 2, 3, 1, 3, 2, 3), array('D', 4, 1, 5, 0, 4, 4)); $p = new PHPlot_truecolor(800, 800); $p->SetTitle("Truecolor Stacked Area chart with alpha channel"); $p->SetDataType('text-data'); $p->SetDataValues($data); $p->SetDataColors(NULL, NULL, 60); // Set alpha for all $p->SetPlotType('stackedarea'); $p->SetDrawXGrid(True); $p->SetXTickLabelPos('none'); $p->SetXTickPos('none'); $p->DrawGraph();
<?php # $Id$ # PHPlot test: Truecolor area plot, alpha gradient require_once 'phplot.php'; $data = array(array('', 90, 60, 45, 40, 20, 0), array('', 100, 80, 55, 40, 22, 15), array('', 83, 65, 47, 47, 24, 20)); $colors = array('red:100', 'red:80', '#ff00003c', 'red:40', 'red:20', 'red'); $p = new PHPlot_truecolor(800, 800); $p->SetTitle("Truecolor Area chart with red alpha gradient"); $p->SetDataType('text-data'); $p->SetDataValues($data); $p->SetDataColors($colors); $p->SetPlotType('area'); $p->SetDrawXGrid(True); $p->SetXTickLabelPos('none'); $p->SetXTickPos('none'); $p->DrawGraph();
// Y range $max_z = 100; // Z range $alpha = 80; // Alpha (transparency) for data colors. 0=opaque, 127=clear. $data = array(); mt_srand(1); for ($x = 0; $x < $n_x; $x++) { $row = array('', mt_rand(0, $max_x - 1)); // Label and X value for ($y = 0; $y < $n_y; $y++) { $row[] = mt_rand(0, $max_y - 1); // Y value $row[] = mt_rand(0, $max_z - 1); // Z value } $data[] = $row; } $legend = array(); for ($y = 0; $y < $n_y; $y++) { $legend[] = "Data Set {$y}"; } $p = new PHPlot_truecolor(800, 600); $p->SetTitle("Bubble Plot - Random data, Truecolor\nTranslucent (alpha={$alpha}) bubbles"); $p->SetDataColors(NULL, NULL, $alpha); $p->SetDataType('data-data-xyz'); $p->SetPlotType('bubbles'); $p->SetDataValues($data); $p->SetLegend($legend); $p->SetPlotAreaWorld(0, 0, $max_x, $max_y); $p->DrawGraph();
<?php # $Id$ # PHPlot test - transparency - truecolor, set data color then set transparent require_once 'phplot.php'; $data = array(array('A', 6), array('B', 4), array('C', 2), array('D', 0)); $p = new PHPlot_truecolor(); $p->SetTitle('Truecolor, Set data color, Set transparent'); $p->SetDataValues($data); $p->SetPlotType('bars'); $p->SetDataColors('yellow'); $p->SetTransparentColor('yellow'); $p->DrawGraph();
<?php # $Id$ # PHPlot test: Truecolor points plot, big overlapped dots require_once 'phplot.php'; mt_srand(0); $data = array(); for ($i = 0; $i < 20; $i++) { $row = array('', $i); for ($j = 0; $j < 30; $j++) { $row[] = mt_rand(0, 100) / 10.0; } $data[] = $row; } $p = new PHPlot_truecolor(800, 600); $p->SetTitle('Truecolor Points plot with varying size poionts'); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetDataColors(NULL, NULL, 90); $p->SetLineWidths(3); $p->SetLineStyles('solid'); $p->SetPointShapes('dot'); $p->SetPointSizes(array(10, 15, 20, 25, 30)); $p->SetPlotType('points'); $p->SetXTickIncrement(1); $p->SetYTickIncrement(1); $p->DrawGraph();