2015-11-09 64 views
1

我有這樣的代碼:PHPLOT如何篩選y軸的標籤

$plot = new PHPlot(); 

//Define some data 
$example_data = array(
    array('Learning',1), 
    array('Reading',3), 
    array('Writing',3), 
    array('Oral Communication',1), 
    array('Numeracy',2), 
); 
$plot->SetDataValues($example_data); 

現在我得到這個圖: enter image description here

我的問題是,我如何可以設置y軸的文字標籤到像靜態值只有1,2,3和4 ..而不只是像現在的3.2,3,2.8,2.6 .. 2,1.8,1.6 ... 1,0.8,... 0 .. ??

是否有可能?

回答

1

一種可能性是使用SetYTickIncrement()方法。

$plot->SetYTickIncrement(1); 

別忘了,還有TuneYAutoTicks()方法。

+0

問題..我添加'$ plot-> TuneYAutoRange(4,'decimal');'我希望它會顯示y軸的最大值爲4,但是當我將圖的值設置爲4時,yaxis標籤變爲1,2,3,4&5 ..我怎樣才能設置它只會顯示1,2,3,4? – gadss

+1

除了這是一個完全不同的問題,而不是你上面發佈的問題,你看看[TuneYAutoRange'文檔(http://www.phplot.com/phplotdocs/TuneYAutoRange.html)?在那裏你可以看到你傳遞的參數與預期的參數不匹配。同樣如文檔中所述,當自動計算沿Y軸的繪圖範圍時,_is用於調整參數。所以範圍和標籤是兩雙不同的鞋子。 – Havelock

+0

我看到使用'$ plot-> SetPlotAreaWorld(NULL,0,NULL,4);' – gadss