jFreeChart setLabelFont 大小在 GroupedStackedBarRenderer 中不起作用

jFreeChart setLabelFont size not working in GroupedStackedBarRenderer

我正在使用 GroupedStackedBarRenderer 在我的图表中允许子类别。我添加子类别并控制子类别的字体大小:

    SubCategoryAxis domainAxis = new SubCategoryAxis("");
    domainAxis.addSubCategory("Skill 1");
    domainAxis.addSubCategory(...)
    domainAxis.setSubLabelFont(new Font("Tahoma", Font.PLAIN, 12));

但是下面这行对大类本身没有影响,日期标签:

    plot.setDomainAxis(domainAxis);
    Font font3 = new Font("Dialog", Font.PLAIN, 16); 
    domainAxis.setLabelFont(font3);

经过深思熟虑,我意识到我需要获取对类别域轴而不是子类别的引用。所以我尝试了以下方法:

   CategoryPlot catPlot = (CategoryPlot) chart.getPlot();
   catPlot.getDomainAxis().setLabelFont(new Font("Tahoma", Font.PLAIN, 20));

但是还是不行。

这是我的图表:

使用 setTickLabelFont() to change the font for the tick labels. Use deriveFont() 保留现有字体属性。

domainAxis.setTickLabelFont(domainAxis.getTickLabelFont().deriveFont(16f));