Java 更改 jfreechart 的域轴标签和范围轴标签的字体大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21401573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 08:29:22 来源:igfitidea点击:
Change font-size of domain axis label and range axis label for jfreechart
提问by newbieinjavaversion2
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".
我的目标是增加"Revenue ($) " 和 "Years" 的大小。但是我不知道怎么做。我可以增加“Apples, Durians,Oranges”和“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);
采纳答案by GrahamA
Use
用
CategoryPlot plot = chart.getCategoryPlot();
Font font3 = new Font("Dialog", Font.PLAIN, 25);
plot.getDomainAxis().setLabelFont(font3);
plot.getRangeAxis().setLabelFont(font3);