My goal is to increase the size of "Revenue ($) " and "Years". But I do not know how. I am able to increase the "Apples, Durians,Oranges" and "2012, 2013".
Below are my codes.
JFreeChart chart = ChartFactory.createBarChart3D("", // chart title
"Years", // domain axis label
"Revenue ($)", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
false, // include legend
false, // tooltips
false);
CategoryPlot plot = chart.getCategoryPlot();
CategoryAxis axis = plot.getDomainAxis();
CategoryPlot p = chart.getCategoryPlot();
ValueAxis axis2 = p.getRangeAxis();
Font font = new Font("Dialog", Font.PLAIN, 25);
axis.setTickLabelFont(font);
Font font2 = new Font("Dialog", Font.PLAIN, 15);
axis2.setTickLabelFont(font2);
LegendTitle legend = new LegendTitle(plot.getRenderer());
Font font3 = new Font("Dialog", Font.PLAIN, 20);
legend.setItemFont(font3);
legend.setPosition(RectangleEdge.BOTTOM);
chart.addLegend(legend);
Change the format of text in category axis labelsRight-click the category axis labels you want to format, and then select Font. On the Font tab, pick the formatting options you want.
To change the text font for any chart element, such as a title or axis, right–click the element, and then click Font. When the Font box appears make the changes you want. Here's an example—suppose you want to change the font size of the chart title. Right click the chart title and click Font.
To change the font units, use the FontUnits property. Setting the font size properties for the associated axes also affects the label font size. The label font size updates to equal the axes font size times the label scale factor. The FontSize property of the axes contains the axes font size.
We can increase the axis label size by specifying the argument base_size=24 inside theme_bw().
Use
CategoryPlot plot = chart.getCategoryPlot();
Font font3 = new Font("Dialog", Font.PLAIN, 25);
plot.getDomainAxis().setLabelFont(font3);
plot.getRangeAxis().setLabelFont(font3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With