1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once('jpgraph/jpgraph.php'); |
---|
3 | require_once('jpgraph/jpgraph_matrix.php'); |
---|
4 | |
---|
5 | $data = array( |
---|
6 | array(0,null,2,3,4,5,6,7,8,9,10,8,6,4,2), |
---|
7 | array(10,9,8,7,6,5,4,3,2,1,0,8,5,9,2), |
---|
8 | array(0,1,2,3,4,5,6,7,8,9,10,2,4,5,7), |
---|
9 | array(10,9,8,17,6,5,4,3,2,1,0,8,6,4,2), |
---|
10 | array(0,1,2,3,4,4,9,7,8,9,10,3,2,7,2), |
---|
11 | array(8,1,2,3,4,8,3,7,8,9,10,5,3,9,1), |
---|
12 | array(10,3,5,7,6,5,4,3,12,1,0,6,5,10,2), |
---|
13 | array(10,9,8,7,6,5,4,3,2,1,NULL,8,6,4,2), |
---|
14 | ); |
---|
15 | |
---|
16 | for($i=0; $i < count($data[0]); ++$i ) { |
---|
17 | $xlabels[$i] = sprintf('xlabel: %02d',$i); |
---|
18 | } |
---|
19 | for($i=0; $i < count($data); ++$i ) { |
---|
20 | $ylabels[$i] = sprintf('ylabel: %02d',$i); |
---|
21 | } |
---|
22 | |
---|
23 | // Setup a nasic matrix graph |
---|
24 | $graph = new MatrixGraph(400,250); |
---|
25 | $graph->SetMarginColor('white'); |
---|
26 | $graph->title->Set('Adding labels on the edges'); |
---|
27 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,14); |
---|
28 | |
---|
29 | // Create one matrix plot |
---|
30 | $mp = new MatrixPlot($data,1); |
---|
31 | $mp->SetModuleSize(13,15); |
---|
32 | $mp->SetCenterPos(0.35,0.45); |
---|
33 | $mp->colormap->SetNullColor('gray'); |
---|
34 | |
---|
35 | // Setup column lablels |
---|
36 | $mp->collabel->Set($xlabels); |
---|
37 | $mp->collabel->SetSide('bottom'); |
---|
38 | $mp->collabel->SetFont(FF_ARIAL,FS_NORMAL,8); |
---|
39 | $mp->collabel->SetFontColor('darkgray'); |
---|
40 | |
---|
41 | // Setup row lablels |
---|
42 | $mp->rowlabel->Set($ylabels); |
---|
43 | $mp->rowlabel->SetSide('right'); |
---|
44 | $mp->rowlabel->SetFont(FF_ARIAL,FS_NORMAL,8); |
---|
45 | $mp->rowlabel->SetFontColor('darkgray'); |
---|
46 | |
---|
47 | // Move the legend more to the right |
---|
48 | $mp->legend->SetMargin(90); |
---|
49 | |
---|
50 | $graph->Add($mp); |
---|
51 | $graph->Stroke(); |
---|
52 | |
---|
53 | ?> |
---|