How to setRange for RangeAxis in CombinedDomainXYPlot

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
reynard80
Posts: 5
Joined: Tue Feb 27, 2018 7:45 pm
antibot: No, of course not.

How to setRange for RangeAxis in CombinedDomainXYPlot

Post by reynard80 » Thu Mar 15, 2018 10:15 pm

I have a CombinedDomainXYPlot with a main XYPlot and a few subplots. For some of the subplots, I want to manually set the range of the y-axis, as it displays values that have a known range (but the datasets do not always contain data that covers values in the complete range).

However, I can't seem to set the range for these subplots as I want to. I've tried to set the range while createing the the XYPlot subplot. The code for creating the subplot:

Code: Select all

XYItemRenderer renderer1 = new StandardXYItemRenderer(); 
NumberAxis range= new NumberAxis("Label"); 
XYPlot subplot1 = new XYPlot(dataSet1, null, range, renderer1);
And then trying to set the range by:

Code: Select all

range.setRange(-axis1upper, axis1upper);
Or:

Code: Select all

range.setUpperBound(axis1upper));
range.setLowerBound(-axis1upper));
But this doesn't work. In the CombinedDomainXYPlot, the subplot is displayed, but not with the correct range on the y-axis. The range on the axis seems to be auto-ranged, based on the dataset, and is smaller than the values set above. How should I solve this?

Post Reply