<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; require_once 'jpgraph/jpgraph_utils.inc.php'; $f = new FuncGenerator('cos($i)', '$i*$i*$i'); list($xdata, $ydata) = $f->E(-M_PI, M_PI, 25); $graph = new Graph\Graph(350, 430); $graph->SetScale("linlin"); $graph->SetShadow(); $graph->img->SetMargin(50, 50, 60, 40); $graph->SetBox(true, 'black', 2); $graph->SetMarginColor('white'); $graph->SetColor('lightyellow'); $graph->SetAxisStyle(AXSTYLE_BOXIN); $graph->xgrid->Show(); //$graph->xaxis->SetLabelFormat('%.0f'); $graph->img->SetMargin(50, 50, 60, 40); $graph->title->Set("Function plot"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->subtitle->Set("(BOXIN Axis style)"); $graph->subtitle->SetFont(FF_FONT1, FS_NORMAL); $lp1 = new Plot\LinePlot($ydata, $xdata); $lp1->SetColor("blue"); $lp1->SetWeight(2); $graph->Add($lp1); $graph->Stroke();
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_bar.php'; require_once 'jpgraph/jpgraph_flags.php'; // Some data $datay1 = array(140, 110, 50); $datay2 = array(35, 90, 190); $datay3 = array(20, 60, 70); // Create the basic graph $graph = new Graph\Graph(300, 200); $graph->SetScale("textlin"); $graph->SetMargin(40, 20, 20, 40); $graph->SetMarginColor('white:0.9'); $graph->SetColor('white'); $graph->SetShadow(); // Apply a perspective transformation at the end $graph->Set3DPerspective(SKEW3D_DOWN, 100, 180); // Adjust the position of the legend box $graph->legend->Pos(0.03, 0.1); // Adjust the color for theshadow of the legend $graph->legend->SetShadow('darkgray@0.5'); $graph->legend->SetFillColor('lightblue@0.1'); $graph->legend->Hide(); // Get localised version of the month names $graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth()); $graph->SetBackgroundCountryFlag('mais', BGIMG_COPY, 50); // Set axis titles and fonts $graph->xaxis->title->Set('Year 2002'); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
// content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; require_once 'jpgraph/jpgraph_log.php'; // Matrix size rxr $r = 10; // Max Interpolation factor $f = 5; for ($i = 1; $i <= $f; ++$i) { $xdata[] = $i; $ydata[] = pow($r * pow(2, $i - 1) - (pow(2, $i) - 1), 2); } $graph = new Graph\Graph(400, 240); $graph->SetScale('intlog'); $graph->SetMargin(50, 50, 20, 30); $graph->SetFrame(false); $graph->SetBox(true, 'black', 2); $graph->SetMarginColor('white'); $graph->SetColor('lightyellow@0.7'); $graph->title->Set('Interpolation growth for size 10x10'); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetTitle('Interpolation factor', 'center'); $graph->xaxis->SetTitleMargin(10); $graph->SetAxisStyle(AXSTYLE_YBOXIN); $graph->xgrid->Show(); $lp1 = new Plot\LinePlot($ydata, $xdata); $lp1->SetColor('darkred'); $lp1->SetWeight(3); $graph->Add($lp1); $graph->Stroke();
for ($i = 0; $i < $n; ++$i) { $y2data[] = $ydata[$i] + 10; } // Negate all data $n = count($ydata); for ($i = 0; $i < $n; ++$i) { $ydata[$i] = round(-$ydata[$i]); $y2data[$i] = round(-$y2data[$i]); } // Basic graph setup $graph = new Graph\Graph(400, 300); $graph->SetScale("linlin"); $graph->SetY2Scale("lin"); $graph->SetMargin(50, 50, 60, 40); $graph->SetMarginColor('darkblue'); $graph->SetColor('darkblue'); // Setup titles $graph->title->Set("Inverting both Y-axis"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->title->SetColor("white"); $graph->subtitle->Set("(Negated Y & Y2 axis)"); $graph->subtitle->SetFont(FF_FONT1, FS_NORMAL); $graph->subtitle->SetColor("white"); // Setup axis $graph->yaxis->SetLabelFormatCallback("_cb_negate"); $graph->xaxis->SetColor("lightblue", "white"); $graph->yaxis->SetColor("lightblue", "white"); $graph->ygrid->SetColor("blue"); // Setup Y2 axis $graph->y2axis->SetLabelFormatCallback("_cb_negate"); $graph->y2axis->SetColor("darkred", "white");
$datax[$i + $numpoints - 1] = $i; } for ($i = 0; $i < $numpoints; ++$i) { $datay[$i + $numpoints - 1] = exp(-$k * $i) * cos(2 * M_PI / 10 * $i) * 14; $datayenv[$i + $numpoints - 1] = exp(-$k * $i) * 14; $datax[$i + $numpoints - 1] = $i; } // Setup the basic parameters for the graph $graph = new Graph\Graph(500, 250); $graph->SetScale("intlin"); $graph->SetShadow(); $graph->SetBox(); $graph->title->Set("Impuls Example 4"); $graph->title->SetFont(FF_FONT1, FS_BOLD); // Set some other color then the boring default $graph->SetColor("lightyellow"); $graph->SetMarginColor("khaki"); // Set legend box specification $graph->legend->SetFillColor("white"); $graph->legend->SetLineWeight(2); // Set X-axis at the minimum value of Y-axis (default will be at 0) $graph->xaxis->SetPos("min"); // "min" will position the x-axis at the minimum value of the Y-axis // Extend the margin for the labels on the Y-axis and reverse the direction // of the ticks on the Y-axis $graph->yaxis->SetLabelMargin(12); $graph->xaxis->SetLabelMargin(6); $graph->yaxis->SetTickSide(SIDE_LEFT); $graph->xaxis->SetTickSide(SIDE_DOWN); // Add mark graph with static lines $line = new PlotLine(HORIZONTAL, 0, "black", 2);
// content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; require_once 'jpgraph/jpgraph_utils.inc.php'; $f = new FuncGenerator('cos($x)*$x'); list($xdata, $ydata) = $f->E(-1.2 * M_PI, 1.2 * M_PI); $f = new FuncGenerator('$x*$x'); list($x2data, $y2data) = $f->E(-2, 2); // Setup the basic graph $graph = new Graph\Graph(450, 350); $graph->SetScale("linlin"); //$graph->SetShadow(); $graph->img->SetMargin(5, 10, 60, 9); $graph->SetBox(true, 'green', 2); $graph->SetMarginColor('black'); $graph->SetColor('black'); // ... and titles $graph->title->Set('Example of Function plot'); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->title->SetColor('lightgreen'); $graph->subtitle->Set("(With some more advanced axis formatting\nHiding first and last label)"); $graph->subtitle->SetFont(FF_FONT1, FS_NORMAL); $graph->subtitle->SetColor('lightgreen'); $graph->xgrid->Show(); $graph->xgrid->SetColor('darkgreen'); $graph->ygrid->SetColor('darkgreen'); $graph->yaxis->SetPos(0); $graph->yaxis->SetWeight(2); $graph->yaxis->HideZeroLabel(); $graph->yaxis->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->SetColor('green', 'green');