if ($i % 10 == 0) { $databarx[] = $i; $databary[] = $datay[$i] / 2; } } // new Graph\Graph with a background image and drop shadow $graph = new Graph\Graph(450, 300); $graph->img->SetMargin(40, 180, 40, 40); $graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME); //$graph->img->SetAntiAliasing(); $graph->SetScale("intlin"); $graph->SetShadow(); $graph->title->Set("Combined bar and line plot"); $graph->subtitle->Set("(\"center\" aligned bars)"); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Slightly adjust the legend from it's default position in the // top right corner. $graph->legend->Pos(0.05, 0.5, "right", "center"); // Create the first line $p1 = new Plot\LinePlot($datay, $datax); $p1->SetWeight(1); $p1->SetColor("red"); $p1->SetLegend("Triumph Tiger -98"); $graph->Add($p1); $b1 = new Plot\BarPlot($databary, $databarx); $b1->SetAbsWidth(10); $b1->SetAlign("center"); $b1->SetShadow(); $graph->Add($b1); $graph->Stroke();
$graph->SetScale("textlin"); // Set title and subtitle $graph->title->Set("Combined bar and line plot"); $graph->subtitle->Set("100 data points, X-Scale: 'text'"); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Make the margin around the plot a little bit bigger // then default $graph->img->SetMargin(40, 140, 40, 80); // Slightly adjust the legend from it's default position in the // top right corner to middle right side $graph->legend->Pos(0.05, 0.5, "right", "center"); // Display every 10:th datalabel $graph->xaxis->SetTextTickInterval(6); $graph->xaxis->SetTextLabelInterval(2); $graph->xaxis->SetTickLabels($databarx); $graph->xaxis->SetLabelAngle(90); // Create a red line plot $p1 = new Plot\LinePlot($datay); $p1->SetColor("red"); $p1->SetLegend("Pressure"); // Create the bar plot $b1 = new Plot\BarPlot($databary); $b1->SetLegend("Temperature"); $b1->SetAbsWidth(6); $b1->SetShadow(); // The order the plots are added determines who's ontop $graph->Add($p1); $graph->Add($b1); // Finally output the image $graph->Stroke();