user522582
user522582

Reputation: 1

JfreeChart: Scatter Plot moving X and Y Axises

I just started using JFreeChart lib. I have a XY scatter chart with some negative plot points. The X and Y axises stay at the bottom and left sides of the chart, and they intercept at negative values. How can I make these axises intercept at (0,0) instead of intercepting at negative values? Thanks in advance.

Upvotes: 0

Views: 1308

Answers (1)

trashgod
trashgod

Reputation: 205785

A scatter plot uses an XYPlot and a NumberAxis for the domain and range. You can get each axis from the plot and invoke setLowerBound(), accordingly.

XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis domainAxis = (NumberAxis) plot.getRangeAxis();
domainAxis.setLowerBound(0);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setLowerBound(0);

Upvotes: 1

Related Questions