Reputation: 12398
Is it possible to remove the distance between the bar and the axis line in a JFreeChart bar chart?
I have produced a bar chart that looks like (A), but I would like it to look like (B), i.e. without any separation between the bar and the (darker) axis line. The axis line is configured as:
plot.getDomainAxis().setAxisLinePaint(new Color(0x333333));
plot.getDomainAxis().setAxisLineStroke(new BasicStroke(1.0f));
I couldn't find the relevant setting for this purpose.
Edit: the demo chart at BarRenderer javadoc, also shows the same issue.
Upvotes: 3
Views: 963
Reputation: 12398
That space is called axis offset. The StandardChartTheme
applies an axisOffset
of 4px.
In order to remove the axis offset configure:
CategoryPlot plot = chart.getCategoryPlot();
plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
The axis offset can also be configured at the theme level: StandardChartTheme.setAxisOffset
Upvotes: 4
Reputation: 103
remove the margin with:
BarRenderer(renderer)).setItemMargin(0.0);
Upvotes: 0