setTickUnit not being adhered to when it should be possible

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
AndrewC
Posts: 2
Joined: Mon Apr 03, 2017 2:12 am
antibot: No, of course not.

setTickUnit not being adhered to when it should be possible

Post by AndrewC » Wed Mar 13, 2019 4:21 am

I am making an xy chart and want to manually set the x axis tick units to 50.

The data is fairly well behaved, and generally is in the range of 0 - 500.

My issue is that for some sets of data it does show tick marks every 50. But for others it shows ticks every 100 instead. As far as I can see there should be no issue with crowding out or anything like that, the charts with ticks every 100 have plenty of room between the ticks to have slotted in an extra tick.

I have attached two example charts generated by the same code. One that works, and one where the chart has decided to display ticks every 100 instead.

https://imgur.com/a/7SDdAFj

The code that I am applying is:

Code: Select all

NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
xAxis.setTickUnit(new NumberTickUnit(50));
Question: How can I force the chart to show ticks every 50 units on the x-axis?

Locked