[42] | 1 | <?php // content="text/plain; charset=utf-8" |
---|
| 2 | require_once('jpgraph/jpgraph.php'); |
---|
| 3 | require_once('jpgraph/jpgraph_matrix.php'); |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | $data = array( |
---|
| 7 | array(0,null,2,3,4,5,6,7,8,9,10,8,6,4,2), |
---|
| 8 | array(10,9,8,7,6,5,4,3,2,1,0,8,5,9,2), |
---|
| 9 | array(0,1,2,3,4,5,6,7,8,9,10,2,4,5,7), |
---|
| 10 | array(10,9,8,17,6,5,4,3,2,1,0,8,6,4,2), |
---|
| 11 | array(0,1,2,3,4,4,9,7,8,9,10,3,2,7,2), |
---|
| 12 | array(8,1,2,3,4,8,3,7,8,9,10,5,3,9,1), |
---|
| 13 | array(10,3,5,7,6,5,4,3,12,1,0,6,5,10,2), |
---|
| 14 | array(10,9,8,7,6,5,4,3,2,1,NULL,8,6,4,2), |
---|
| 15 | ); |
---|
| 16 | |
---|
| 17 | $nx = count($data[0]); |
---|
| 18 | $ny = count($data); |
---|
| 19 | |
---|
| 20 | for( $i=0; $i < $ny; ++$i ) { |
---|
| 21 | for( $j=0; $j < $nx; ++$j ) { |
---|
| 22 | $csimtargets[$i][$j] = '#'.sprintf('%02sd',$i)."-".sprintf('%02sd',$j); |
---|
| 23 | } |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | for($i=0; $i < $nx; ++$i ) { |
---|
| 28 | $collabels[$i] = sprintf('column label: %02d',$i); |
---|
| 29 | $collabeltargets[$i] = '#'.sprintf('collabel: %02d',$i); |
---|
| 30 | |
---|
| 31 | } |
---|
| 32 | for($i=0; $i < $ny; ++$i ) { |
---|
| 33 | $rowlabels[$i] = sprintf('row label: %02d',$i); |
---|
| 34 | $rowlabeltargets[$i] = '#'.sprintf('rowlabel: %02d',$i); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | // Setup a nasic matrix graph |
---|
| 38 | $graph = new MatrixGraph(400,350); |
---|
| 39 | |
---|
| 40 | $graph->SetBackgroundGradient('lightsteelblue:0.8','lightsteelblue:0.3'); |
---|
| 41 | $graph->title->Set('CSIM with matrix'); |
---|
| 42 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,16); |
---|
| 43 | $graph->title->SetColor('white'); |
---|
| 44 | |
---|
| 45 | // Create one matrix plot |
---|
| 46 | $mp = new MatrixPlot($data,1); |
---|
| 47 | $mp->SetModuleSize(13,15); |
---|
| 48 | $mp->SetCenterPos(0.35,0.6); |
---|
| 49 | $mp->colormap->SetNullColor('gray'); |
---|
| 50 | |
---|
| 51 | // Setup column lablels |
---|
| 52 | $mp->collabel->Set($collabels); |
---|
| 53 | $mp->collabel->SetSide('top'); |
---|
| 54 | $mp->collabel->SetFont(FF_ARIAL,FS_NORMAL,8); |
---|
| 55 | $mp->collabel->SetFontColor('lightgray'); |
---|
| 56 | |
---|
| 57 | // Setup row lablels |
---|
| 58 | $mp->rowlabel->Set($rowlabels); |
---|
| 59 | $mp->rowlabel->SetSide('right'); |
---|
| 60 | $mp->rowlabel->SetFont(FF_ARIAL,FS_NORMAL,8); |
---|
| 61 | $mp->rowlabel->SetFontColor('lightgray'); |
---|
| 62 | |
---|
| 63 | $mp->rowlabel->SetCSIMTargets($rowlabeltargets); |
---|
| 64 | $mp->collabel->SetCSIMTargets($collabeltargets); |
---|
| 65 | |
---|
| 66 | // Move the legend more to the right |
---|
| 67 | $mp->legend->SetMargin(90); |
---|
| 68 | $mp->legend->SetColor('white'); |
---|
| 69 | $mp->legend->SetFont(FF_VERDANA,FS_BOLD,10); |
---|
| 70 | |
---|
| 71 | $mp->SetCSIMTargets($csimtargets); |
---|
| 72 | |
---|
| 73 | $graph->Add($mp); |
---|
| 74 | $graph->StrokeCSIM(); |
---|
| 75 | |
---|
| 76 | ?> |
---|