Search code examples
javachartshistogramjfreechart

How can I remove the reflection effect in JFreeChart?


I am drawing a histogram in JFreeChart. The columns of the histogram are colored red. But each column also has a white stripe on its left side. This stripe looks like a reflection effect. How can I remove the reflection effect to get solid colored bars instead? For more information, please see the attached screenshot.

Histogram with Reflection Effect


Solution

  • The following code sets the bar painter for the histogram to the StandardXYBarPainter which does not draw a reflection effect. For more information, please see the related questions JFreeChart BarChart -> NO gradient and How to change JFreeChart vertical bar to a solid color? When I searched for my question, I did not see those questions because I searched for the word 'reflection' instead of 'gradient'. @trashgod referred me to these questions in his comment.

    ((XYBarRenderer) ((XYPlot) histogram.getPlot()).getRenderer()).setBarPainter(new StandardXYBarPainter());