title: Setting multiple colours in 3D BarChart - JFreeChart
body: <p>I'm new to the JFreeChart library. I'm currently playing around with the 3D Bar Chart, and I wonder if it is possible to have each generated 3D bar in different colours? All of them are currently yellow as shown below.</p>
  
  <p>Is there something I can override to change the colours?</p>
  
  <p>Thanks.</p>
  
  <p><strong><em>Code:</em></strong> </p>
  
  <pre><code>import java.awt.Dimension;
  import javax.swing.JPanel;
  import org.jfree.chart.*;
  import org.jfree.chart.axis.CategoryAxis;
  import org.jfree.chart.axis.CategoryLabelPositions;
  import org.jfree.chart.plot.CategoryPlot;
  import org.jfree.chart.plot.PlotOrientation;
  import org.jfree.chart.renderer.category.BarRenderer;
  import org.jfree.chart.renderer.category.CategoryItemRenderer;
  import org.jfree.data.category.CategoryDataset;
  import org.jfree.data.category.DefaultCategoryDataset;
  import org.jfree.ui.ApplicationFrame;
  import org.jfree.ui.RefineryUtilities;
  
  public class jfree extends ApplicationFrame
  {
      {
          // set a theme using the new shadow generator feature available in
          // 1.0.14 - for backwards compatibility it is not enabled by default
          ChartFactory.setChartTheme(StandardChartTheme.createDarknessTheme());
      }
  
      public jfree(String s)
      {
          super(s);
          JPanel jpanel = createDemoPanel();
          jpanel.setPreferredSize(new Dimension(500, 270));
          setContentPane(jpanel);
      }
  
      private static CategoryDataset createDataset()
      {
          DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
                      defaultcategorydataset.addValue(25D, "Series 1", "Pipe Stricking");
                      defaultcategorydataset.addValue(17D, "Series 1", "Lost Circulation");
                      defaultcategorydataset.addValue(34D, "Series 1", "Hole Deviation");
                      defaultcategorydataset.addValue(12D, "Series 1", "Kick Blowout");
                      defaultcategorydataset.addValue(54D, "Series 1", "Formation Change");
                      defaultcategorydataset.addValue(10D, "Series 1", "Borehole Instability");
                      defaultcategorydataset.addValue(19D, "Series 1", "Cavings/Pack-offs");
          return defaultcategorydataset;
      }
  
      private static JFreeChart createChart(CategoryDataset categorydataset)
      {
          JFreeChart jfreechart = ChartFactory.createBarChart3D("IPS", "", "Value", categorydataset, PlotOrientation.VERTICAL, false, false, false);
                      CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
                      CategoryAxis categoryaxis = categoryplot.getDomainAxis();
                      categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.2D));
                      CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
                      categoryitemrenderer.setBaseItemLabelsVisible(true);
                      BarRenderer barrenderer = (BarRenderer)categoryitemrenderer;
                      barrenderer.setItemMargin(200D);
          return jfreechart;
      }
  
      public static JPanel createDemoPanel()
      {
          JFreeChart jfreechart = createChart(createDataset());
          return new ChartPanel(jfreechart);
      }
  
      public static void main(String args[])
      {
          jfree jfree = new jfree("3D Bar Chart Demo 3");
          jfree.pack();
          RefineryUtilities.centerFrameOnScreen(jfree);
          jfree.setVisible(true);
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/6CJKy.jpg" alt="JFree3DBarChart"></p>