高斯图表与jpgraph

时间:2011-05-23 17:19:13

标签: php jpgraph

我试图在php中绘制高斯图表。我找到了jpgraph库,但我不知道如何使用$x$y数据。请知道如何申报轴的人。谢谢。这是我的代码:

while ($row = pg_fetch_assoc($sql))
{
    $ydata = array();
    $xdata = array();
    $ydata[] = abs(($row['grade']-$miu)/$sigma);
    $xdata[] = 0;
    for ($i = 0; $i <= 60; $i+=10) // put z value
    {
        $xdata[] = 0 + $i;
        $ydata[] = 0 + $i;
    }       
    $graph = new Graph(600,400,"auto");
    $graph->SetScale("linlin");     
    $lplot = new LinePlot($ydata,$xdata);
    $lplot->SetColor("blue");
    $lplot->SetWeight(2);
    $graph->Add($lplot);
    // Add data to X coordinate
    $graph->xaxis->SetTickLabels($xdata);       
    // Display the graph
    $graph->Stroke();
}

1 个答案:

答案 0 :(得分:0)

我已经解决了。

while ($row = pg_fetch_assoc($sql))
   {      
      $z[$i] = ($row['grade'] - $miu)/$sigma; // $z => arreglo con notas normalizadas
      $ordenada[$i] = (1/($sigma*sqrt(pi())))*(exp(-0.5*(($row['grade']-$miu)*($row['grade'] - 57))/(12*12)));                      
      $i++;
   }
//rest of code
$p1 = new LinePlot($ordenada);
$graph->Add($p1);