can i get rid of the origin(0,0) if i use autorange

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

can i get rid of the origin(0,0) if i use autorange

Post by Robert Fearn » Fri Nov 22, 2002 6:37 pm

I am plotting data where the data starts at values much greater than zero ,but the origin(0,0) point is always included when it plots using autorange(true). The result is the data appears on the right hand side of the plot looking as though it is on top of each other.

Is there a way to autorange the data to only inlclude the data added to the series.
My code is of the form:

chart2 = ChartFactory.createScatterPlot("Models", "Time (ms)", "Number",dataset2, true);
chart2.addTitle(new TextTitle(datasource));
XYPlot Subplot2 = chart2.getXYPlot();

ValueAxis axis= Subplot2.getDomainAxis(); //x axis
axis.setAutoRange(true);

I know the numberaxis has autoRangeIncludesZero but i can't work out how to use it.

Any help or tips would be great

Dave Gilbert

Re: can i get rid of the origin(0,0) if i use autorange

Post by Dave Gilbert » Fri Nov 22, 2002 6:44 pm

Hi Robert,

You just need to cast the domain axis to a NumberAxis, then set the autoRangeIncludesZero attribute to false:

NumberAxis axis = (NumberAxis) subplot2.getDomainAxis();
axis.setAutoRange(true);
axis.setAutoRangeIncludesZero(false);

Regards,

DG

Locked