<?php

// content="text/plain; charset=utf-8"
// Basic contour plot example
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$data = array(array(12, 7, 3, 15), array(18, 5, 1, 9), array(13, 9, 5, 12), array(5, 3, 8, 9), array(1, 8, 5, 7));
// Basic contour graph
$graph = new Graph\Graph(350, 250);
$graph->SetScale('intint');
// Show axis on all sides
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
// Adjust the margins to fit the margin
$graph->SetMargin(30, 100, 40, 30);
// Setup
$graph->title->Set('Basic contour plot with multiple axis');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
// A simple contour plot with default arguments (e.g. 10 isobar lines)
$cp = new Plot\ContourPlot($data, 10, 2);
// Display the legend
$cp->ShowLegend();
$graph->Add($cp);
// ... and send the graph back to the browser
$graph->Stroke();
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$ydata = array(12, 19, 3, 9, 15, 10);
// The code to setup a very basic graph
$graph = new Graph\Graph(200, 150);
$graph->SetScale('intlin');
$graph->SetMargin(30, 15, 40, 30);
$graph->SetMarginColor('white');
$graph->SetFrame(true, 'blue', 3);
$graph->title->Set('Label background');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->subtitle->SetColor('darkred');
$graph->subtitle->Set('"LABELBKG_YAXIS"');
$graph->SetAxisLabelBackground(LABELBKG_YAXIS, 'orange', 'red', 'lightblue', 'red');
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new Plot\LinePlot($ydata);
$graph->Add($p1);
// Output graph
$graph->Stroke();
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$datay = array(10, 29, 3, 6);
// Create the graph.
$graph = new Graph\Graph(200, 200);
$graph->SetScale('textlin');
$graph->SetMargin(25, 10, 20, 25);
$graph->SetBox(true);
// Add 10% grace ("space") at top and botton of Y-scale.
$graph->yscale->SetGrace(10);
// Create a bar pot
$bplot = new Plot\BarPlot($datay);
$bplot->SetFillColor("lightblue");
$graph->ygrid->Show(false);
// .. and add the plot to the graph
$graph->Add($bplot);
// Add band
$band = new Plot\PlotBand(HORIZONTAL, BAND_3DPLANE, 15, 35, 'khaki4');
$band->SetDensity(40);
$band->ShowFrame(true);
$graph->AddBand($band);
// Set title
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->title->SetColor('darkred');
$graph->title->Set('BAND_3DPLANE, Density=40');
$graph->Stroke();
Exemple #4
0
<?php

// content="text/plain; charset=utf-8"
// Contour plot example
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$data = array(array(0.5, 1.1, 1.5, 1, 2.0, 3, 3, 2, 1, 0.1), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 1, 4), array(0.9, 2.0, 2.1, 3, 6.0, 7, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1.5, 1, 2), array(0.8, 2.0, 3.0, 3, 4.0, 4, 3, 2.4, 2, 3), array(0.6, 1.1, 1.5, 1, 4.0, 3.5, 3, 2, 3, 4), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 2.7, 4), array(0.8, 2.0, 3.0, 3, 5.5, 6, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1, 0.5, 0.2));
// Setup a basic graph context with some generous margins to be able
// to fit the legend
$graph = new Graph\Graph(500, 380);
$graph->SetMargin(40, 140, 60, 40);
$graph->title->Set('Example of contour plot');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 14);
// For contour plots it is custom to use a box style ofr the axis
$graph->legend->SetPos(0.05, 0.5, 'right', 'center');
$graph->SetScale('intint');
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
$graph->xgrid->Show();
$graph->ygrid->Show();
// A simple contour plot with default arguments (e.g. 10 isobar lines)
$cp = new Plot\ContourPlot($data);
// Display the legend
$cp->ShowLegend();
// Make the isobar lines slightly thicker
$cp->SetLineWeight(2);
$graph->Add($cp);
// ... and send the graph back to the browser
$graph->Stroke();
Exemple #5
0
// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Some (random) data
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Size of the overall graph
$width = 350;
$height = 250;
// Create the graph and set a scale.
// These two calls are always required
$graph = new Graph\Graph($width, $height);
$graph->SetScale('intlin');
$graph->SetShadow();
// Setup margin and titles
$graph->SetMargin(40, 20, 20, 40);
$graph->title->Set('Calls per operator');
$graph->subtitle->Set('(March 12, 2008)');
$graph->xaxis->title->Set('Operator');
$graph->yaxis->title->Set('# of calls');
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->SetColor('blue');
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot->SetColor('blue');
$lineplot->SetWeight(2);
// Two pixel wide
// Add an image mark scaled to 50%
$lineplot->mark->SetType(MARK_IMG_DIAMOND, 'red', 0.5);
// Add the plot to the graph
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Some data
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(350, 250);
$graph->SetScale("textlin");
$graph->SetMargin(40, 40, 50, 50);
// Setup the grid and plotarea box
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->setColor('darkgray');
$graph->SetBox(true);
// Steup graph titles
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->Set('Using background image');
$graph->subtitle->SetFont(FF_COURIER, FS_BOLD, 11);
$graph->subtitle->Set('"BGIMG_COPY"');
$graph->subtitle->SetColor('darkred');
// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg', BGIMG_COPY);
$graph->SetBackgroundImageMix(25);
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
Exemple #7
0
<?php

// content="text/plain; charset=utf-8"
// Contour example 05
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$data = array(array(0.0, 0.001, 0.002, 0.005, -0.003, -0.053, -0.156, -0.245, -0.235, -0.143, -0.056, -0.014, -0.002, 0.0, 0.0), array(0.0, 0.002, 0.008999999999999999, 0.015, -0.04, -0.308, -0.826, -1.257, -1.188, -0.719, -0.28, -0.07000000000000001, -0.011, -0.001, 0.0), array(0.001, 0.005, 0.024, 0.047, -0.103, -0.878, -2.432, -3.767, -3.591, -2.166, -0.828, -0.195, -0.026, -0.001, 0.0), array(0.001, 0.007, 0.046, 0.145, 0.096, -0.913, -3.472, -6.042, -6.038, -3.625, -1.283, -0.235, -0.005, 0.007, 0.002), array(-0.003, -0.008999999999999999, 0.008999999999999999, 0.208, 0.734, 0.864, -0.9370000000000001, -3.985, -4.866, -2.781, -0.5600000000000001, 0.194, 0.151, 0.043, 0.007), array(-0.013, -0.07199999999999999, -0.229, -0.259, 0.652, 2.587, 3.058, 0.661, -1.097, 0.014, 1.336, 1.154, 0.474, 0.113, 0.017), array(-0.028, -0.171, -0.653, -1.397, -1.091, 1.421, 3.424, 1.942, 0.403, 1.784, 2.986, 2.12, 0.821, 0.191, 0.028), array(-0.037, -0.231, -0.9340000000000001, -2.255, -2.78, -0.699, 1.692, 0.981, 0.198, 2.199, 3.592, 2.515, 0.968, 0.225, 0.033), array(-0.031, -0.201, -0.829, -2.076, -2.82, -1.399, 0.61, 0.408, 0.122, 1.882, 3.004, 2.085, 0.8, 0.186, 0.027), array(-0.018, -0.115, -0.469, -1.133, -1.343, 0.011, 1.921, 2.256, 1.824, 2.115, 2.141, 1.312, 0.481, 0.11, 0.016), array(-0.007, -0.039, -0.13, -0.152, 0.5600000000000001, 2.77, 5.591, 6.719, 5.583, 3.646, 1.973, 0.832, 0.251, 0.052, 0.007), array(-0.001, -0.003, 0.024, 0.273, 1.297, 3.628, 6.515, 7.832, 6.517, 3.875, 1.69, 0.546, 0.13, 0.022, 0.003), array(0.0, 0.004, 0.036, 0.215, 0.837, 2.171, 3.809, 4.578, 3.81, 2.218, 0.913, 0.268, 0.056, 0.008, 0.001), array(0.0, 0.002, 0.014, 0.076, 0.284, 0.721, 1.257, 1.511, 1.257, 0.728, 0.294, 0.083, 0.017, 0.002, 0.0), array(0.0, 0.0, 0.003, 0.016, 0.057, 0.144, 0.25, 0.3, 0.25, 0.144, 0.058, 0.016, 0.003, 0.0, 0.0));
// Setup a basic graph context with some generous margins to be able
// to fit the legend
$graph = new Graph\Graph(480, 390);
$graph->SetMargin(40, 120, 60, 50);
$graph->title->Set("Contour plot, high contrast color");
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->SetMargin(10);
// For contour plots it is custom to use a box style ofr the axis
$graph->SetScale('intint', 0, 56, 0, 56);
// Setup axis and grids
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
$graph->xgrid->Show(true);
$graph->ygrid->Show(true);
// A simple contour plot with 10 isobar lines and flipped Y-coordinates
// Make the data smoother by interpolate the original matrice by a factor of two
// which will make each grid cell half the original size
$cp = new Plot\ContourPlot($data, 10, 3);
$cp->UseHighContrastColor(true);
// Display the legend
$cp->ShowLegend();
// Make the isobar lines slightly thicker
$graph->Add($cp);
// ... and send the graph back to the browser
Exemple #8
0
$data2y = array(180, 200, 220, 190, 170, 195, 190, 210, 200, 205, 195, 150);
//bar3
$data3y = array(220, 230, 210, 175, 185, 195, 200, 230, 200, 195, 180, 130);
$data4y = array(40, 45, 70, 80, 50, 75, 70, 70, 80, 75, 80, 50);
$data5y = array(20, 20, 25, 22, 30, 25, 35, 30, 27, 25, 25, 45);
//line1
$data6y = array(50, 58, 60, 58, 53, 58, 57, 60, 58, 58, 57, 50);
foreach ($data6y as &$y) {
    $y -= 10;
}
// Create the graph. These two calls are always required
$graph = new Graph\Graph(750, 320, 'auto');
$graph->SetScale("textlin");
$graph->SetY2Scale("lin", 0, 90);
$graph->SetY2OrderBack(false);
$graph->SetMargin(35, 50, 20, 5);
$theme_class = new UniversalTheme();
$graph->SetTheme($theme_class);
$graph->yaxis->SetTickPositions(array(0, 50, 100, 150, 200, 250, 300, 350), array(25, 75, 125, 175, 275, 325));
$graph->y2axis->SetTickPositions(array(30, 40, 50, 60, 70, 80, 90));
$months = $gDateLocale->GetShortMonth();
$months = array_merge(array_slice($months, 3, 9), array_slice($months, 0, 3));
$graph->SetBox(false);
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
// Setup month as labels on the X-axis
$graph->xaxis->SetTickLabels($months);
// Create the bar plots
$b1plot = new Plot\BarPlot($data1y);
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
require_once 'jpgraph/jpgraph_line.php';
// Some "random" data
$ydata = array(10, 120, 80, 190, 260, 170, 60, 40, 20, 230);
$ydata2 = array(10, 70, 40, 120, 200, 60, 80, 40, 20, 5);
// Get a list of month using the current locale
$months = $gDateLocale->GetShortMonth();
// Create the graph.
$graph = new Graph\Graph(300, 200);
$graph->SetScale("textlin");
$graph->SetMarginColor('white');
// Adjust the margin slightly so that we use the
// entire area (since we don't use a frame)
$graph->SetMargin(30, 1, 20, 5);
// Box around plotarea
$graph->SetBox();
// No frame around the image
$graph->SetFrame(false);
// Setup the tab title
$graph->tabtitle->Set('Year 2003');
$graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 10);
// Setup the X and Y grid
$graph->ygrid->SetFill(true, '#DDDDDD@0.5', '#BBBBBB@0.5');
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->SetColor('gray');
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle('dashed');
$graph->xgrid->SetColor('gray');
// Setup month as labels on the X-axis
Exemple #10
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
use Amenadiel\JpGraph\Util;
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
$ydata2 = array(1, 19, 15, 7, 22, 14, 5, 9, 21, 13);
$timer = new Util\JpgTimer();
$timer->Push();
// Create the graph. These two calls are always required
$graph = new Graph\Graph(300, 200);
$graph->SetScale("textlin");
$graph->SetMargin(40, 20, 20, 60);
$graph->title->Set("Timing a graph");
$graph->footer->right->Set('Timer (ms): ');
$graph->footer->right->SetFont(FF_COURIER, FS_ITALIC);
$graph->footer->SetTimer($timer);
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot2 = new Plot\LinePlot($ydata2);
// Add the plot to the graph
$graph->Add($lineplot);
$graph->Add($lineplot2);
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$lineplot->SetColor("blue");