Search code examples
jfreechart

How can I display fewer labels on the X-axis when it is an instance of CategoryAxis? (JFreeChart library)


I have a CategoryAxis used with a BarChart where I have too many labels to be readable. I would like to set a visible interval for the labels, so let's say each ten values the label is printed. I read some posts where setTickUnit() method is recommended, but such method doesn't exist in CategoryAxis.

Here you can see a sample of what I am referring to, as you see I have tens of dates so you can't read them:

enter image description here

Any pointer or recommendation?

Thanks!


Solution

  • You can find a pretty good explanation of the problem (and some solutions) in the FAQ section of the JFreeChart homepage. You might be better of with an XYPlot and an XYBarRenderer.