Easy Chart XYBoxAnnotation -layer background

I’m not able to set XYBoxAnnotation to Layer.BACKGROUND for subplots
(pens are drawn behind the box)
grateful for tips!

Code in configureChart:
from java.awt import Color, BasicStroke, Font
from org.jfree.chart.annotations import XYBoxAnnotation
from org.jfree.ui import Layer

for index, plot in enumerate(chart.getPlot().getSubplots()):
		index = index + 1
		if index ==1:
				title = 'Level' 
				stroke = BasicStroke(0)
				outline = Color(0, 0, 0)
				fill = Color(184,218,255)
				startX = self.startDate.getTime() 
				endX = self.endDate.getTime()
				bottomY = 70
				topY = 90
                                    overlay = XYBoxAnnotation(startX, bottomY, endX, topY, stroke, outline, fill)
                                    chart.getPlot().getSubplots().get(0).addAnnotation(overlay)
				#Layer.BACKGROUND
		elif index ==2:
			title = 'Speed' 
		elif index ==3:
					title = 'Water' 
		elif index ==4:
				title = 'Temp.' 
		elif index ==5:
				title = 'Titan' 
		labelAxis = NumberAxis("Subplot %s Title" % (index + 1))
		labelAxis = NumberAxis(title)

		
		labelAxis.setLabelFont(Font("Tahoma", Font.BOLD, 16))
		labelAxis.setTickLabelsVisible(False)
		labelAxis.setTickMarksVisible(False)
		labelAxis.setAxisLineVisible(False)
		plot.setDomainAxis(1, labelAxis)
		#print index, plot.getRangeAxis().getAutoRangeMinimumSize()

Add the annotation to the renderer.

renderer = plot.getRenderer()
renderer.addAnnotation(overlay,Layer.BACKGROUND)
3 Likes

Great!
Thank you!