source: trunk/xgraph/jpgraph/Examples/contourex03.php

Last change on this file was 42, checked in by marrucho, 10 years ago
File size: 1.6 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2// Contour plot example
3
4require_once ('jpgraph/jpgraph.php');
5require_once ('jpgraph/jpgraph_contour.php');
6
7$data = array( 
8            array (0.5,1.1,1.5,1,2.0,3,3,2,1,0.1),
9            array (1.0,1.5,3.0,5,6.0,2,1,1.2,1,4),
10            array (0.9,2.0,2.1,3,6.0,7,3,2,1,1.4),
11            array (1.0,1.5,3.0,4,6.0,5,2,1.5,1,2),
12            array (0.8,2.0,3.0,3,4.0,4,3,2.4,2,3),
13            array (0.6,1.1,1.5,1,4.0,3.5,3,2,3,4),
14            array (1.0,1.5,3.0,5,6.0,2,1,1.2,2.7,4),
15            array (0.8,2.0,3.0,3,5.5,6,3,2,1,1.4),
16            array (1.0,1.5,3.0,4,6.0,5,2,1,0.5,0.2));
17
18
19// Setup a basic graph context with some generous margins to be able
20// to fit the legend           
21$graph = new Graph(500,380);
22$graph->SetMargin(40,140,60,40);       
23
24// Enable antialias. Note with antiaaliasing only line weight=1 is supported.
25$graph->img->SetAntiAliasing();
26
27$graph->title->Set("Example of contour plot");
28$graph->title->SetFont(FF_ARIAL,FS_BOLD,14);
29
30// For contour plots it is custom to use a box style ofr the axis
31$graph->legend->SetPos(0.05,0.5,'right','center');
32$graph->SetScale('intint');
33$graph->SetAxisStyle(AXSTYLE_BOXOUT);
34$graph->xgrid->Show();
35$graph->ygrid->Show();
36
37
38// A simple contour plot with 19 isobars and flipped vertical range
39$cp = new ContourPlot($data,10,true);
40
41// Display the legend
42$cp->ShowLegend();
43
44// Invert the legend to th lowest isobar is on top
45$cp->Invertlegend();
46$graph->Add($cp);
47
48// ... and send the graph back to the browser
49$graph->Stroke();
50
51?>
Note: See TracBrowser for help on using the repository browser.