2015-11-09 126 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