Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the axis value font on a JFreeChart

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.

like image 801
chris Avatar asked Sep 01 '11 16:09

chris


2 Answers

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)
like image 192
Neo Avatar answered Oct 01 '22 03:10

Neo


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

like image 22
toto2 Avatar answered Oct 01 '22 03:10

toto2