Reputation: 47
I am currently using JFreeChart to display some data in a line graph. The labels on my x-axis (integers) are too dense, so I hope to display only the multiplies of 5 (1, 5, 10…). How can I achieve that?
Upvotes: 1
Views: 1184
Reputation: 47
Thanks to trashgod. The NumberAxis
does help in customizing the axis scale. I did use CategoryChart
at first and the problem get solved when I switched to XYChart. Below is the snippet about using NumberAxis
to change the x-axis scale.
NumberAxis xAxis = new NumberAxis();
xAxis.setTickUnit(new NumberTickUnit(10));
XYPlot plot = lineChart.getXYPlot();
plot.setDomainAxis(xAxis);
Upvotes: 1