How to change the axis value font on a JFreeChart

chris picture chris · Sep 1, 2011 · Viewed 14.1k times · Source

Just as the title says, if I have a JFreeChart (or want to create one) how do I specify the font that is used for the values on the axis? Not the axis label, but the actual values. Specifically I just want to make the font a little bigger.

Answer

Neo picture Neo · May 2, 2013

For Range Axis

 CategoryPlot p = chart.getCategoryPlot(); 
 ValueAxis axis = p.getRangeAxis();

For Domian Axis

 CategoryPlot p = chart.getCategoryPlot(); 
 CategoryAxis axis = p.getDomainAxis();

then set the font like

Font font = new Font("Dialog", Font.PLAIN, 30);
axis.setTickLabelFont(font)