$p->SetDataType('data-data-error'); $p->SetDataValues($data); #print_r($p); #exit; # We don't use the data labels (all set to '') so might as well turn them off: #$p->SetXDataLabelPos('none'); # Turn off unused ticks and tick labels $p->SetXTickLabelPos('none'); $p->SetXTickPos('none'); # Need to set area and ticks to get reasonable choices. $p->SetPlotAreaWorld(0, 0, 11, 25); $p->SetXTickIncrement(1); # Draw both grids: $p->SetDrawXGrid(True); $p->SetDrawYGrid(True); # Is default # Options for error bars: if (isset($tp['EBShape'])) { $p->SetErrorBarShape($tp['EBShape']); } if (isset($tp['EBLWidth'])) { $p->SetErrorBarLineWidth($tp['EBLWidth']); } if (isset($tp['EBColors'])) { $p->SetErrorBarColors($tp['EBColors']); } if (isset($tp['EBSize'])) { $p->SetErrorBarSize($tp['EBSize']); } $p->SetPlotType('lines'); $p->DrawGraph();
$graph->SetYTitle($ylbl, $which_ytitle_pos); $graph->SetLegend(array("A", "Bee", "Cee", "Dee")); $graph->SetFileFormat($which_fileformat); $graph->SetPlotType($which_plot_type); $graph->SetUseTTF($which_use_ttf); $graph->SetYTickIncrement($which_yti); $graph->SetXTickIncrement($which_xti); $graph->SetXTickLength($which_xtl); $graph->SetYTickLength($which_ytl); $graph->SetXTickCrossing($which_xtc); $graph->SetYTickCrossing($which_ytc); $graph->SetXTickPos($which_xtick_pos); $graph->SetYTickPos($which_ytick_pos); $graph->SetShading($which_shading); $graph->SetLineWidth($which_line_width); $graph->SetErrorBarLineWidth($which_errorbar_line_width); $graph->SetDrawDashedGrid($which_dashed_grid); switch ($which_draw_grid) { case 'x': $graph->SetDrawXGrid(TRUE); $graph->SetDrawYGrid(FALSE); break; case 'y': $graph->SetDrawXGrid(FALSE); $graph->SetDrawYGrid(TRUE); break; case 'both': $graph->SetDrawXGrid(TRUE); $graph->SetDrawYGrid(TRUE); break; case 'none':
$data[] = array("{$label[$i]}", $i + 1, $a, $b, $c); } //Define the data for error bars $graph->SetDataType("linear-linear-error"); //Must be first thing //Set the Graph particulars $graph->SetPrecisionX(0); $graph->SetPrecisionY(0); $graph->SetUseTTF("0"); $graph->SetDrawYGrid("1"); // 1 = true $graph->SetDataValues($data); $graph->SetImageArea(600, 400); $graph->SetVertTickIncrement(""); $graph->SetHorizTickIncrement(1); $graph->SetErrorBarLineWidth(1); $graph->SetYScaleType("log"); $graph->SetPointShape("halfline"); $graph->SetErrorBarShape("line"); $graph->SetPlotType("points"); $graph->SetXGridLabelType("title"); $graph->SetXLabel("Day"); $graph->SetYLabel("index"); $graph->SetTitle("Stock Market Data"); //$graph->SetErrorBarColors(array("blue","red","green","black")); $graph->SetDataColors(array("blue", "green", "yellow", "red"), array("black")); //$graph->SetPlotAreaWorld(0,5,32,30); //$graph->SetPlotAreaPixels(150,50,600,400); /* //Other settings $graph->SetPlotBgColor(array(222,222,222));
<?php # PHPlot Example: Point chart with error bars require_once 'phplot.php'; $data = array(array('', 1, 23.5, 5, 5), array('', 2, 20.1, 3, 3), array('', 3, 19.1, 2, 2), array('', 4, 16.8, 3, 3), array('', 5, 18.4, 4, 6), array('', 6, 20.5, 3, 2), array('', 7, 23.2, 4, 4), array('', 8, 23.1, 5, 2), array('', 9, 24.5, 2, 2), array('', 10, 28.1, 2, 2)); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); $plot->SetPlotType('points'); $plot->SetDataType('data-data-error'); $plot->SetDataValues($data); # Main plot title: $plot->SetTitle('Points Plot With Error Bars'); # Set data range and tick increments to get nice even numbers: $plot->SetPlotAreaWorld(0, 0, 11, 40); $plot->SetXTickIncrement(1); $plot->SetYTickIncrement(5); # Draw both grids: $plot->SetDrawXGrid(True); $plot->SetDrawYGrid(True); # Is default # Set some options for error bars: $plot->SetErrorBarShape('tee'); # Is default $plot->SetErrorBarSize(10); $plot->SetErrorBarLineWidth(2); # Use a darker color for the plot: $plot->SetDataColors('brown'); $plot->SetErrorBarColors('brown'); # Make the points bigger so we can see them: $plot->SetPointSizes(10); $plot->DrawGraph();
} else { # Vertical plot $p->SetPlotAreaWorld(0, NULL, 10, NULL); $p->SetXTitle('X Axis - Independent variable'); $p->SetYTitle('Y Axis - Dependent variable'); $p->SetYDataLabelPos('plotin'); # Tick labels below, Axis Data labels above, so both can be seen. $p->SetXTickLabelPos('plotdown'); $p->SetXDataLabelPos('plotup'); } $p->SetPlotBorderType('full'); # With error plots, the default 90 degree position for data value labels # will overlay the error bar, so move them to another angle: $p->data_value_label_angle = 135; # Turn off the grid lines, so the error bars are move visible. $p->SetDrawXGrid(False); $p->SetDrawYGrid(False); # Style variations: if (!empty($eb_lwidth)) { $p->SetErrorBarLineWidth($eb_lwidth); } if (isset($eb_shape)) { $p->SetErrorBarShape($eb_shape); } if (isset($eb_size)) { $p->SetErrorBarSize($eb_size); } if (!empty($eb_colors)) { $p->SetErrorBarColors($eb_colors); } $p->DrawGraph();