Can I remove a matplotlib artist such as a patch by using blitting?
"""Some background code:"""
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
self.figure = Figure()
self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvas(self, -1, self.figure)
To add a patch to a matplotlib plot by using blit you can do the following:
"""square is some matplotlib patch"""
self.axes.add_patch(square)
self.axes.draw_artist(square)
self.canvas.blit(self.axes.bbox)
This works. However, can I use blit to remove this same artist from the plot?
I managed to remove it with square.remove()
and I can update the plot with the self.canvas.draw()
function. But ofcourse this is slow and I would like to instead make use of blitting.
"""square is some matplotlib patch"""
square.remove()
self.canvas.draw()
The following does not work:
square.remove()
self.canvas.blit(self.axes.bbox)