1 | <?php // content="text/plain; charset=utf-8"
|
---|
2 | // Contour plot example 04
|
---|
3 |
|
---|
4 | require_once ('jpgraph/jpgraph.php');
|
---|
5 | require_once ('jpgraph/jpgraph_contour.php');
|
---|
6 |
|
---|
7 | $data = array(
|
---|
8 | array (12,12,10,10,8,4),
|
---|
9 | array (10,10,8,14,10,3),
|
---|
10 | array (7,7,13,17,12,8),
|
---|
11 | array (4,5,8,12,7,6),
|
---|
12 | array (10,8,7,8,10,4));
|
---|
13 |
|
---|
14 | // Setup a basic graph context with some generous margins to be able
|
---|
15 | // to fit the legend
|
---|
16 | $graph = new Graph(500,380);
|
---|
17 | $graph->SetMargin(40,140,60,40);
|
---|
18 |
|
---|
19 | $graph->title->Set("Example of interpolated contour plot");
|
---|
20 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,14);
|
---|
21 | $graph->title->SetMargin(10);
|
---|
22 |
|
---|
23 | // For contour plots it is custom to use a box style ofr the axis
|
---|
24 | $graph->legend->SetPos(0.05,0.5,'right','center');
|
---|
25 | $graph->SetScale('intint');
|
---|
26 |
|
---|
27 | // Setup axis and grids
|
---|
28 | $graph->SetAxisStyle(AXSTYLE_BOXOUT);
|
---|
29 | $graph->xgrid->SetLineStyle('dashed');
|
---|
30 | $graph->xgrid->Show(true);
|
---|
31 | $graph->ygrid->SetLineStyle('dashed');
|
---|
32 | $graph->ygrid->Show(true);
|
---|
33 |
|
---|
34 | // A simple contour plot with 10 isobar lines and flipped Y-coordinates
|
---|
35 | // Make the data smoother by interpolate the original matrice by a factor of two
|
---|
36 | // which will make each grid cell half the original size
|
---|
37 | $cp = new ContourPlot($data,10, 2);
|
---|
38 |
|
---|
39 | $cp->UseHighContrastColor(true);
|
---|
40 |
|
---|
41 | // Display the legend
|
---|
42 | $cp->ShowLegend();
|
---|
43 |
|
---|
44 | // Make the isobar lines slightly thicker
|
---|
45 | $graph->Add($cp);
|
---|
46 |
|
---|
47 | // ... and send the graph back to the browser
|
---|
48 | $graph->Stroke();
|
---|
49 |
|
---|
50 | ?>
|
---|