Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change font-size of domain axis label and range axis label for jfreechart

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.

image

    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); 
like image 733
newbieinjavaversion2 Avatar asked Jan 28 '14 09:01

newbieinjavaversion2


People also ask

How do I change axis label font?

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.

How do I change font size in Axis?

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.

How do I change the font size of axis labels in Matlab?

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.

Which argument can be used to increase the font size of the axis labels?

We can increase the axis label size by specifying the argument base_size=24 inside theme_bw().


1 Answers

Use

CategoryPlot plot = chart.getCategoryPlot();
Font font3 = new Font("Dialog", Font.PLAIN, 25); 
plot.getDomainAxis().setLabelFont(font3);
plot.getRangeAxis().setLabelFont(font3);
like image 89
GrahamA Avatar answered Sep 24 '22 19:09

GrahamA