Using 1.0.19 JFreeChart, I'm not able to figure out how to plot my desired log-scale chart.
If I use LogarithmicAxis, how to get it to disable showing labels for the minor-axis tick marks? JFreeChart appears to set a few minor tick mark labels whenever it thinks it has room. Here's the relevant code I'm using:
Code: Select all
XYPlot plot = jchart.getXYPlot();
LogarithmicAxis xAxis = new LogarithmicAxis("Frequency (Hz)");
xAxis.setAutoTickUnitSelection(false);
xAxis.setLog10TickLabelsFlag(true); // this never works; labels always come out as the full number
//xAxis.setExpTickLabelsFlag(true); // this works
xAxis.setMinorTickMarksVisible(false); // does not work; minor tick mark labels still appear
xAxis.setTickMarksVisible(false);
xAxis.setAxisLineVisible(false);
xAxis.setRange(xLower, xUpper);
...
plot.setDomainGridlinePaint(new Color(0xb0,0xb0,0xb0)); // domain is x-axis
plot.setDomainGridlineStroke(new BasicStroke(0.5f));
plot.setDomainMinorGridlinePaint(new Color(0xb0,0xb0,0xb0));
plot.setDomainMinorGridlineStroke(new BasicStroke(0.5f));
plot.setDomainMinorGridlinesVisible(true);
plot.setDomainAxis(xAxis);
Code: Select all
XYPlot plot = jchart.getXYPlot();
LogAxis xAxis = new LogAxis("Frequency (Hz)");
xAxis.setAutoTickUnitSelection(false);
xAxis.setMinorTickCount(9); // changing the integer argument has no effect on chart
xAxis.setBase(10);
xAxis.setTickMarksVisible(false);
xAxis.setAxisLineVisible(false);
xAxis.setRange(xLower, xUpper);
...
plot.setDomainGridlinePaint(new Color(0xb0,0xb0,0xb0)); // domain is x-axis
plot.setDomainGridlineStroke(new BasicStroke(0.5f));
plot.setDomainMinorGridlinePaint(new Color(0xb0,0xb0,0xb0));
plot.setDomainMinorGridlineStroke(new BasicStroke(0.5f));
plot.setDomainMinorGridlinesVisible(true);
plot.setDomainAxis(xAxis);
UPDATE
I saw this post from 2008: http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=23833
which is exactly the behavior I'm seeing for the number of minor tick marks created by LogAxis default. That is, LogAxis creates 10 minor tick marks when it should be 9 (LogarithmicAxis does not have this bug). David Gilbert reports in that post that the fix was implemented in subversion for 1.0.10 release, but I'm still seeing the bug in 1.0.19.
Somehow I can't get xAxis.setMinorTickCount(9) to work for me. I change the argument's integer, but it has no effect.