Move Patch Rather Than Remove It
I have a graph that is gradually revealed. Since this should happen with a huge dataset and on several subplots simultaneously, I was planning to move the patch rather than remove
Solution 1:
Maybe this works for you. Instead of removing the patch, you just update its position and its width (with rect.set_x(left_x)
and rect.set_width(width)
), and then redraw the canvas. Try replacing your loop with this (note that the Rectangle
is created once, before the loop):
rect = plt.Rectangle((0, 0), nmax, 1, zorder=10)
ax.add_patch(rect)
for i in range(nmax):
rect.set_x(i)
rect.set_width(nmax - i)
fig.canvas.draw()
plt.pause(0.1)
Post a Comment for "Move Patch Rather Than Remove It"