JFreeChart Can't Hide Second Legend Item?

The following is working in my report to hide the first legend item. However, I want to hide the second. Logic says to pass index 1 instead of 0, but this doesn't work. What am I missing?

xyplot = chart.plot
xyplot.getRenderer().setSeriesVisibleInLegend(0, False) # this works

image

xyplot = chart.plot
xyplot.getRenderer().setSeriesVisibleInLegend(1, False) # this does nothing

image

For now, I've set the pens so the one I want to hide is first. This works but is not a solution. If anyone has any insight on this please let me know!

You probably want to use .getRenderer(int), not plain .getRenderer().

2 Likes