{ public function GET_rgb_array() { return $this->rgb_array; } } $p = new PHPlot_pv(800, 700); # Use internal color map rgb_array to get a list of colors: $colors = array_keys($p->GET_rgb_array()); sort($colors); $nc = count($colors); # Make a data array with 1 point, $nc data sets: $dp = array(''); for ($i = 0; $i < $nc; $i++) { $dp[] = $nc - $i; } $data = array($dp); $p->SetPlotType('bars'); $p->SetDataType('text-data'); $p->SetDataValues($data); # Use all colors: $p->SetDataColors($colors); $p->SetShading(0); # Make a legend with all the color names: $p->SetLegend($colors); $p->SetPlotAreaWorld(0.1, 0, NULL, NULL); $p->SetTitle('PHPlot Default Color Map'); $p->SetXTickLabelPos('none'); $p->SetXTickPos('none'); $p->SetYTickIncrement(1); $p->DrawGraph();
} test('New PHPlot object', $p, $dcol, $bcol, $ecol); $p->SetDataColors('red'); $p->SetDataBorderColors('blue'); $p->SetErrorBarColors('green'); test('Then set color arrays to single word', $p, 1, 1, 1); $p = new PHPlot_pv(); $p->SetDataColors($c6); $p->SetDataBorderColors($c6); $p->SetErrorBarColors($c6); test('New object, set color arrays to array of 6', $p, 6, 6, 6); $p->SetDataColors(); $p->SetDataBorderColors(); $p->SetErrorBarColors(); test('Then use NULL, should be ignored', $p, 6, 6, 6); $p->SetDataColors(''); $p->SetDataBorderColors(''); $p->SetErrorBarColors(''); test('Then set color arrays to default, using empty string', $p, $dcol, $bcol, $ecol); $p = new PHPlot_pv(); $p->SetDataColors($c6); $p->SetDataColors(False); $p->SetDataBorderColors(False); $p->SetErrorBarColors(False); test('New object, using False also sets color arrays to default', $p, $dcol, $bcol, $ecol); # ======== End of test cases and error reporting ========== echo "setcolors results: {$n_tests} test cases, {$n_pass} pass, {$n_fail} fail\n"; if ($n_fail > 0) { exit(1); } # PHPlot test suite requires falling off the end, not exit, on success.
$data[] = $row; } $plot->SetImageBorderType('plain'); $plot->SetPlotType('linepoints'); $plot->SetDataType('data-data'); $plot->SetDataValues($data); # Main plot title: $plot->SetTitle("Linepoints Plot - Showing {$n_shapes} Point Shapes\n{$title_suffix}"); # Increase X range to make room for the legend. $plot->SetPlotAreaWorld(0, 0, $ppl, $n_shapes + $ppl - 2); # Turn off tick labels and ticks - not used for this plot. $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->SetYTickLabelPos('none'); $plot->SetYTickPos('none'); # Need some different colors; $plot->SetDataColors($colors); # If not showing default shapes, show all shapes: if (!isset($use_default_shapes)) { $plot->SetPointShapes($shapes); } # Make the points bigger so we can see them: $plot->SetPointSizes(10); # Make the lines all be solid: $plot->SetLineStyles('solid'); # Also show that as the legend: $plot->SetLegend($shapes); # Draw no grids: $plot->SetDrawXGrid(False); $plot->SetDrawYGrid(False); $plot->DrawGraph();