setting horizontal axis values

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
anup

setting horizontal axis values

Post by anup » Thu Apr 18, 2002 4:26 am

In the horizontal y axis, what should i do if i wanted whole numbers like 1 or 2 to appear instead of the 0.25 , 0.5.
thanks
anup

David Gilbert

Re: setting horizontal axis values

Post by David Gilbert » Thu Apr 18, 2002 8:18 am

For any axis that is a subclass of NumberAxis, the following should work:

NumberAxis axis = (NumberAxis)plot.getRangeAxis();
// or NumberAxis axis = (NumberAxis)plot.getDomainAxis();
axis.setStandardTickUnits(TickUnits.createIntegerTickUnits());

You are free to create your own collection of standard tick units if you want different choices. The axis will automatically select an appropriate unit from the collection depending on the space available for the axis.

Regards,

DG.

Locked