2016-11-19 11 views
0

私はPHPで、jpgグラフで実現されたマルチグラフを持っています:最初と2番目のプロットは左の軸と同じ縮尺で、3番目のプロットは異なる縮尺または値の範囲を持ち、軸は右にあります。コード付き :jpgraphの複数のy軸

$width=700; 
    $height=500; 

// Create the graph and set a scale. 
// These two calls are always required 
$graph = new Graph($width, $height); 

$graph->SetScale("intlin"); // X and Y axis 
$graph->SetY2Scale("lin"); // Y2 axis 
$theme_class=new UniversalTheme; 

$graph->SetTheme($theme_class); 
$graph->img->SetAntiAliasing(false); 
$graph->title->Set('Filled Y-grid'); 
$graph->SetBox(false); 

$graph->xaxis->title->Set("Days"); 
$graph->img->SetAntiAliasing(); 

// Create the first line 
$p1 = new LinePlot($ydata1); 
$graph->Add($p1); 
$p1->SetColor("#0033FF"); 
$p1->SetLegend('Rain'); 

// Create the second line 
$p2 = new LinePlot($ydata2); 
$graph->Add($p2); 
$p2->SetColor("#33FFFF"); 
$p2->SetLegend('Irrigation'); 

// Create the third line 
$p3 = new LinePlot($ydata3); 
$graph->AddY2($p3); 
$p3->SetColor("#000000"); 
$p3->SetLegend('Relative Soil Moisture'); 

$graph->legend->SetFrameWeight(0); 

// Setup a title for the graph 
$graph->title->Set($titolo); 
$nome_img=substr($titolo, 0, -10); 

// Display the graph 
$graph->Stroke("tmp/graph_$nome_img.png"); 

echo "<img src=\"tmp/graph_$nome_img.png\"> "; 

私は左にのみ軸を持って、右の軸は表示されません。あなたは添付immageを参照してください。 何か問題がありますか?おかげさまで

enter image description here

答えて

0

私は、あなたがグラフの余白を設定するので、あなたの規模を見るために持っていると思います。そこには表示されません:

$graph->SetMargin(50,50,50,50); 
関連する問題