1 | <?php
|
---|
2 | require_once ('jpgraph/jpgraph.php');
|
---|
3 | require_once ('jpgraph/jpgraph_matrix.php');
|
---|
4 | require_once ('jpgraph/jpgraph_iconplot.php');
|
---|
5 |
|
---|
6 | $data = array(
|
---|
7 | array(0,1,2,3,4,5,6,7,8,9,10),
|
---|
8 | array(10,9,8,7,6,5,4,3,2,1,0),
|
---|
9 | array(0,1,2,3,4,5,6,7,8,9,10),
|
---|
10 | array(10,9,8,17,6,5,4,3,2,1,0),
|
---|
11 | array(0,1,2,3,4,4,9,7,8,9,10),
|
---|
12 | array(8,1,2,3,4,8,3,7,8,9,10),
|
---|
13 | array(10,3,5,7,6,5,4,3,12,1,0),
|
---|
14 | array(10,9,8,7,6,5,4,3,2,1,0),
|
---|
15 | );
|
---|
16 | // Interpolate the data a factor of 4 to get some mroe
|
---|
17 | // data points
|
---|
18 | doMeshInterpolate($data,4);
|
---|
19 |
|
---|
20 | // Setup a timer
|
---|
21 | $timer = new JpgTimer();
|
---|
22 | $timer->Push();
|
---|
23 |
|
---|
24 | //--------------------------------------------------------------
|
---|
25 | // Setup a basic matrix graph
|
---|
26 | //--------------------------------------------------------------
|
---|
27 | $width = 740; $height = 500;
|
---|
28 | $graph = new MatrixGraph($width,$height);
|
---|
29 | $graph->SetMargin(1,2,70,1);
|
---|
30 | $graph->SetColor('white');
|
---|
31 | $graph->SetMarginColor('#fafafa');
|
---|
32 | $graph->title->Set('Intro matrix graph');
|
---|
33 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,14);
|
---|
34 |
|
---|
35 | // Setup the background image
|
---|
36 | $graph->SetBackgroundImage('fireplace.jpg',BGIMG_FILLPLOT);
|
---|
37 | $graph->SetBackgroundImageMix(50);
|
---|
38 |
|
---|
39 | // Setup the timer in the right footer
|
---|
40 | $graph->footer->SetTimer($timer);
|
---|
41 | $graph->footer->right->SetColor('white');
|
---|
42 |
|
---|
43 | //--------------------------------------------------------------
|
---|
44 | // Create the 2 matrix plots
|
---|
45 | //--------------------------------------------------------------
|
---|
46 | $mp = array(); $n = 2;
|
---|
47 | for($i=0; $i < $n; ++$i){
|
---|
48 | $mp[$i] = new MatrixPlot($data);
|
---|
49 | $mp[$i]->colormap->SetMap($i);
|
---|
50 | $mp[$i]->SetSize(300,250);
|
---|
51 | $mp[$i]->SetLegendLayout(1);
|
---|
52 | $mp[$i]->SetAlpha(0.2);
|
---|
53 |
|
---|
54 | // Make the legend slightly longer than default
|
---|
55 | $mp[$i]->legend->SetSize(20,280);
|
---|
56 | }
|
---|
57 | $mp[1]->colormap->SetMap(3);
|
---|
58 |
|
---|
59 | $hor1 = new LayoutHor(array($mp[0],$mp[1]));
|
---|
60 | $hor1->SetCenterPos(0.5,0.5);
|
---|
61 |
|
---|
62 | $graph->Add($hor1);
|
---|
63 |
|
---|
64 | //--------------------------------------------------------------
|
---|
65 | // Add texts to the graph
|
---|
66 | //--------------------------------------------------------------
|
---|
67 | $txts = array(
|
---|
68 | array('Temperature gradient',$width/2,80),
|
---|
69 | array('Heat color map',200,110),
|
---|
70 | array('High contrast map',560,110));
|
---|
71 |
|
---|
72 | $n=count($txts);
|
---|
73 | $t=array();
|
---|
74 | for($i=0; $i < $n; ++$i){
|
---|
75 | $t[$i] = new Text($txts[$i][0],$txts[$i][1],$txts[$i][2]);
|
---|
76 | $t[$i]->SetFont(FF_ARIAL,FS_BOLD,14);
|
---|
77 | $t[$i]->SetColor('white');
|
---|
78 | $t[$i]->SetAlign('center','top');
|
---|
79 | }
|
---|
80 | $graph->Add($t);
|
---|
81 |
|
---|
82 | //--------------------------------------------------------------
|
---|
83 | // Add Jpgraph logo to top left corner
|
---|
84 | //--------------------------------------------------------------
|
---|
85 | $icon = new IconPlot('jpglogo.jpg',2,2,0.9,50);
|
---|
86 | $graph->Add($icon);
|
---|
87 |
|
---|
88 | $graph->Stroke();
|
---|
89 | ?>
|
---|