JFreeChart x axis Format

六眼飞鱼酱① 提交于 2019-12-13 05:02:32

问题


How to format x axis labels? I have a chart(look at attach1)

I need to change x axis labels to the labels in the next attach (but with the same chart)


回答1:


To set the label of the axis (in your example "counts") call

XYPlot plot = (XYPlot) chart.getPlot();
plot.getDomainAxis().setLabel("counts");

To change the number format of the axis call

XYPlot plot = (XYPlot) chart.getPlot();
((NumberAxis)plot.getDomainAxis()).setNumberFormatOverride(new DecimalFormat("0"));

To change the visible range of the plot call

XYPlot plot = (XYPlot) chart.getPlot();
((NumberAxis)plot.getDomainAxis()).setRange(0,20);


来源:https://stackoverflow.com/questions/26108850/jfreechart-x-axis-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!