source: trunk/xgraph/jpgraph/Examples/contourex01.php @ 42

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 1.4 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$graph->title->Set('Example of contour plot');
25$graph->title->SetFont(FF_ARIAL,FS_BOLD,14);
26
27// For contour plots it is custom to use a box style ofr the axis
28$graph->legend->SetPos(0.05,0.5,'right','center');
29$graph->SetScale('intint');
30$graph->SetAxisStyle(AXSTYLE_BOXOUT);
31$graph->xgrid->Show();
32$graph->ygrid->Show();
33
34
35// A simple contour plot with default arguments (e.g. 10 isobar lines)
36$cp = new ContourPlot($data);
37
38// Display the legend
39$cp->ShowLegend();
40
41// Make the isobar lines slightly thicker
42$cp->SetLineWeight(2);
43$graph->Add($cp);
44
45// ... and send the graph back to the browser
46$graph->Stroke();
47
48?>
Note: See TracBrowser for help on using the repository browser.