[ Index ] |
|
Code source de jpGraph 2.2 |
1 <?php 2 include ("../jpgraph.php"); 3 include ("../jpgraph_scatter.php"); 4 include ("../jpgraph_line.php"); 5 6 // Create some "fake" regression data 7 $datay = array(); 8 $datay2 = array(); 9 $datax = array(); 10 $a=rand(-3,3); 11 $b=rand(-5,5); 12 for($x=0; $x<20; ++$x) { 13 $datay[] = $a*$x + $b; 14 $datay2[] = $a*$x + $b + rand(-30,30); 15 $datax[] = $x; 16 } 17 18 // Create the graph 19 $graph = new Graph(300,200,'auto'); 20 $graph->SetScale("linlin"); 21 22 // Setup title 23 $graph->title->Set("Example of linear regression"); 24 $graph->title->SetFont(FF_FONT1,FS_BOLD); 25 26 // make sure that the X-axis is always at the 27 // bottom at the plot and not just at Y=0 which is 28 // the default position 29 $graph->xaxis->SetPos('min'); 30 31 // Create the scatter plot with some nice colors 32 $sp1 = new ScatterPlot($datay2,$datax); 33 $sp1->mark->SetType(MARK_FILLEDCIRCLE); 34 $sp1->mark->SetFillColor("red"); 35 $sp1->SetColor("blue"); 36 $sp1->SetWeight(3); 37 $sp1->mark->SetWidth(4); 38 39 // Create the regression line 40 $lplot = new LinePlot($datay); 41 $lplot->SetWeight(2); 42 $lplot->SetColor('navy'); 43 44 // Add the pltos to the line 45 $graph->Add($sp1); 46 $graph->Add($lplot); 47 48 // ... and stroke 49 $graph->Stroke(); 50 51 ?> 52 53
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:27:55 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |