I was manually creating a range for the y-axis on the graph I was creating, but saw that there were a few properties indicating that JFreeChart can generate them for you.
It already generates a sensible maximum value for the y-axis, but no matter what I try and do, I cannot get the setAutoRangeIncludesZero(boolean)
to actually be taken into account when generating the graph.
Here is the relevant code that generates and manipulates the graph:
barChart = ChartFactory.createBarChart("Classifiers' accuracy for " + position + "s",
"Missing Value Imputation Method Combination",
"Average accuracy (%)", dataset,
PlotOrientation.VERTICAL, true, false, false);
plot = (CategoryPlot)barChart.getCategoryPlot();
xAxis = (CategoryAxis)plot.getDomainAxis();
xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
yAxis = (NumberAxis)plot.getRangeAxis();
yAxis.setAutoRangeIncludesZero(false);
barChartImage = new File(position + "-Classification" + ".png");
I have also tried first getting the y-axis as a ValueAxis
, using setAutoRange(true)
and then casting the y-axis to a NumberAxis
and using setAutoRangeIncludesZero(false)
.
Every time, the y-axis still starts at 0.
plot.getDataRange (yAxis)
,yAxis.getRangeType ()
,yAxis.getAutoRangeIncludesZero ()
,yAxis.getFixedAutoRange ()
,yAxis.getAutoRangeMinimumSize ()
,yAxis.getAutoRangeStickyZero ()
.plot.getRange(yAxis)
= 0.0 and 70.45 (don't know why it starts at 0, none of the data in the dataset is 0)yAxis.getRangeType()
=RangeType.FULL
yAxis.getAutoRangeIncludesZero()
= falseyAxis.getFixedAutoRange()
= 0.0yAxis.getAutoRangeMinimumSize()
= 1.0E-8yAxis.getAutoRangeStickyZero()
= true