How to change the axis value font on a JFreeChart

14,515

Solution 1

Try setTickLabelFont(java.awt.Font font) on the relevant 'Axis'.

Solution 2

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)
Share:
14,515
chris
Author by

chris

Updated on June 04, 2022

Comments

  • chris
    chris almost 2 years

    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.

  • Adam Hughes
    Adam Hughes over 8 years
    Thank you for providing full answer; accepted answer's pointing to API doc didn't get me there (complete jfreehcart noob)
  • JohnJ
    JohnJ over 7 years
    setTicklabelFont -> setTickLabelFont