JFreeChart对齐柱状图左侧。

huangapple go评论180阅读模式
英文:

JFreeChart align Bar Chart left

问题

使用JFreeChart打印了一个条形图。但是,如果我想使用setCategoryMargin(-2)在我的CategoryAxis上使条形更靠近彼此,那么条形图似乎会居中对齐。

有没有办法将整个图形与左侧对齐,使其直接位于y轴旁边?或者减小条之间的间距,而不使图表居中?

英文:

I printed a bar chart using JFreeChart. But if I want to make the bars closer to each other using setCategoryMargin(-2) on my CategoryAxis, the Bar Chart appears to align in the center.

Is there a way to align the entire graph to the left, so it's directly next to the y-axis ? Or reduce the space between the bars without the chart getting centered ?

答案1

得分: 0

setCategoryMargin(float) 用于调整类别之间的间距,接受一个介于 0.0 和 1.0 之间的值(其中 1.0 表示使用可用空间的 100% 作为边距!)。因此,使用负值(-2)可能不会产生预期的结果。

阅读更多信息:https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/CategoryAxis.html#setCategoryMargin-double-

您可以尝试设置不同的较低正边距,以看看哪个适合您的需求。

英文:

The setCategoryMargin(float) is used to adjust the space between categories and accepts a value between 0.0 and 1.0 (where 1.0 means 100% of the available space is used as the margin(!)). So using a negative value (-2) may not give the expected result.

Read more: https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/CategoryAxis.html#setCategoryMargin-double-

You can try setting different lower positive margin to to see what suits your needs.

huangapple
  • 本文由 发表于 2023年6月26日 21:45:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76557278.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定