[42] | 1 | <?php // content="text/plain; charset=utf-8" |
---|
| 2 | // Contour example 05 |
---|
| 3 | |
---|
| 4 | require_once ('jpgraph/jpgraph.php'); |
---|
| 5 | require_once ('jpgraph/jpgraph_contour.php'); |
---|
| 6 | |
---|
| 7 | $data = array( |
---|
| 8 | array(0.000,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.000,0.000), |
---|
| 9 | array(0.000,0.002,0.009,0.015,-0.040,-0.308,-0.826,-1.257,-1.188,-0.719,-0.280,-0.070,-0.011,-0.001,0.000), |
---|
| 10 | 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.000), |
---|
| 11 | 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), |
---|
| 12 | array(-0.003,-0.009,0.009,0.208,0.734,0.864,-0.937,-3.985,-4.866,-2.781,-0.560,0.194,0.151,0.043,0.007), |
---|
| 13 | array(-0.013,-0.072,-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), |
---|
| 14 | array(-0.028,-0.171,-0.653,-1.397,-1.091,1.421,3.424,1.942,0.403,1.784,2.986,2.120,0.821,0.191,0.028), |
---|
| 15 | array(-0.037,-0.231,-0.934,-2.255,-2.780,-0.699,1.692,0.981,0.198,2.199,3.592,2.515,0.968,0.225,0.033), |
---|
| 16 | array(-0.031,-0.201,-0.829,-2.076,-2.820,-1.399,0.610,0.408,0.122,1.882,3.004,2.085,0.800,0.186,0.027), |
---|
| 17 | 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.110,0.016), |
---|
| 18 | array(-0.007,-0.039,-0.130,-0.152,0.560,2.770,5.591,6.719,5.583,3.646,1.973,0.832,0.251,0.052,0.007), |
---|
| 19 | array(-0.001,-0.003,0.024,0.273,1.297,3.628,6.515,7.832,6.517,3.875,1.690,0.546,0.130,0.022,0.003), |
---|
| 20 | array(0.000,0.004,0.036,0.215,0.837,2.171,3.809,4.578,3.810,2.218,0.913,0.268,0.056,0.008,0.001), |
---|
| 21 | array(0.000,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.000), |
---|
| 22 | array(0.000,0.000,0.003,0.016,0.057,0.144,0.250,0.300,0.250,0.144,0.058,0.016,0.003,0.000,0.000), |
---|
| 23 | ); |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | // Setup a basic graph context with some generous margins to be able |
---|
| 27 | // to fit the legend |
---|
| 28 | $graph = new Graph(480,390); |
---|
| 29 | $graph->SetMargin(40,120,60,50); |
---|
| 30 | |
---|
| 31 | $graph->title->Set("Contour plot, high contrast color"); |
---|
| 32 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,12); |
---|
| 33 | $graph->title->SetMargin(10); |
---|
| 34 | |
---|
| 35 | // For contour plots it is custom to use a box style ofr the axis |
---|
| 36 | $graph->SetScale('intint',0,56,0,56); |
---|
| 37 | |
---|
| 38 | // Setup axis and grids |
---|
| 39 | $graph->SetAxisStyle(AXSTYLE_BOXOUT); |
---|
| 40 | $graph->xgrid->Show(true); |
---|
| 41 | $graph->ygrid->Show(true); |
---|
| 42 | |
---|
| 43 | // A simple contour plot with 10 isobar lines and flipped Y-coordinates |
---|
| 44 | // Make the data smoother by interpolate the original matrice by a factor of two |
---|
| 45 | // which will make each grid cell half the original size |
---|
| 46 | $cp = new ContourPlot($data,10, 3); |
---|
| 47 | |
---|
| 48 | $cp->UseHighContrastColor(true); |
---|
| 49 | |
---|
| 50 | // Display the legend |
---|
| 51 | $cp->ShowLegend(); |
---|
| 52 | |
---|
| 53 | // Make the isobar lines slightly thicker |
---|
| 54 | $graph->Add($cp); |
---|
| 55 | |
---|
| 56 | // ... and send the graph back to the browser |
---|
| 57 | $graph->Stroke(); |
---|
| 58 | |
---|
| 59 | ?> |
---|