I am trying to draw a rectangle on top of a data plot in matplotlib
. To do this, I have this code
import matplotlib.patches as patches
import matplotlib.pyplot as pl...fig = pl.figure()
ax=fig.add_axes([0,0,1,1])
ax.add_patch(
patches.Rectangle((776820, 5000), # (x,y)3000, # width3500, # heightfill=False)
)
ax.plot(signal)
ax.plot(fit)
...
When I do this, the rectangle is behind the data, however. It doesn't appear to matter if I add the rectnagle before or after plotting the actual data. How can I ensure that the rectangle is the top-most element in the figure?