2016-11-19 135 views
0

我在PHP中使用jpg图形实现了一个多图:第一个和第二个plot在左边具有相同的比例尺,第三个plot具有不同的比例或值范围,该轴位于右侧。 随着代码: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);