删除 JFreeChart 中条形图和轴线之间的分隔

Remove separation between bar and axis line in JFreeChart

是否可以去除JFreeChart 条形图中条形与轴线之间的距离?

我制作了一个看起来像 (A) 的条形图,但我希望它看起来像 (B),即条形图和(较暗的)轴线之间没有任何分隔。轴线配置为:

    plot.getDomainAxis().setAxisLinePaint(new Color(0x333333));
    plot.getDomainAxis().setAxisLineStroke(new BasicStroke(1.0f));

我找不到为此目的的相关设置。

编辑:BarRenderer javadoc 中的演示图表也显示了相同的问题。

删除边距:

BarRenderer(renderer)).setItemMargin(0.0);

那个space就叫axis offsetStandardChartTheme 应用 4px 的 axisOffset

为了去除轴偏移配置:

CategoryPlot plot = chart.getCategoryPlot();
plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));

轴偏移也可以在主题级别配置:StandardChartTheme.setAxisOffset