Here is the code for the current state of the tug-of-war between England and Scotland:
public TugOfWar(String s) {
super(s);
// data set
DefaultKeyedValues2DDataset dataset = new DefaultKeyedValues2DDataset();
dataset.addValue(0.2, "England", "");
dataset.addValue(0.8, "Scotland", "");
JFreeChart chart = ChartFactory.createStackedBarChart("tug-of-war",
"", "", dataset, PlotOrientation.HORIZONTAL, true, false, false);
CategoryPlot plot = chart.getCategoryPlot();
// customize axis
SymbolAxis axis = new SymbolAxis("", new String[]{
"England", "draw", "Scotland"});
axis.setRange(0, 2d);
plot.setRangeAxis(axis);
// customize renderer
BarRenderer renderer = new StackedBarRenderer();
renderer.setBase(0.8);
renderer.setMinimumBarLength(0);
renderer.setMaximumBarWidth(0.5);
renderer.setItemMargin(0.0);
renderer.setDrawBarOutline(true);
renderer.setShadowVisible(true);
renderer.setBarPainter(new StandardBarPainter());
plot.setRenderer(renderer);
// customize background
plot.setBackgroundPaint(Color.WHITE);
plot.setDomainGridlinePaint(Color.lightGray);
plot.setRangeGridlinePaint(Color.lightGray);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
ChartPanel chartpanel = new ChartPanel(chart);
chartpanel.setPreferredSize(new Dimension(600, 270));
setContentPane(chartpanel);
}
public static void main(String args[]) {
TugOfWar tugOfWar = new TugOfWar("Tug of war");
tugOfWar.pack();
RefineryUtilities.centerFrameOnScreen(tugOfWar);
tugOfWar.setVisible(true);
}
Which leads us to this:
As you can see, the center of the plot's background has been set to white (correct), but the left and right margin are still light grey. How does one set the color of the outer parts of the background ?