14

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); 
Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
newbieinjavaversion2
  • 489
  • 5
  • 12
  • 23
  • 2
    The fastest way to find the answer to this would be to read the API docs (http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/CategoryAxis.html) and scan all the setXXX() methods (including the inherited methods). setLabelFont() should jump out at you as something worth trying. – David Gilbert Jan 28 '14 at 12:46
  • See also [*Help with font size please*](http://www.jfree.org/forum/viewtopic.php?f=3&t=120504). – trashgod Oct 03 '19 at 07:41

1 Answers1

32

Use

CategoryPlot plot = chart.getCategoryPlot();
Font font3 = new Font("Dialog", Font.PLAIN, 25); 
plot.getDomainAxis().setLabelFont(font3);
plot.getRangeAxis().setLabelFont(font3);
Carlos López Marí
  • 1,432
  • 3
  • 18
  • 45
GrahamA
  • 5,875
  • 29
  • 39