Hi, I want to update the legend with the latest y-value in an animated plot. The graph animation is done as the following official matplotlib example, where the implementation of the animated figures are done by subclassing the animation.TimedAnimation class. To exemplify the issue I've modified the example:
The legeend will not update unless the self._drawn_artists is commented out. But I want to keep using that inherited method otherwise the window/animation is lagging seriously.
Worth noting that the example you refer to has been removed from the docs in #10125. The reason was
relies on subclassing private attributes of TimedAnimation, would
better be replaced by a FuncAnimation example, overly complex
I think one would rather create the figure, axes, lines etc. outside of any subclass and create a FuncAnimation that updates the lines.
Concerning the legend, it should be possible to blit that as well as long as it (a) is returned by the animating function, (b) spacially resides inside an axes.
Worth noting that the example you refer to has been removed from the docs in #10125. The reason was
relies on subclassing private attributes of TimedAnimation, would
better be replaced by a FuncAnimation example, overly complex
I think one would rather create the figure, axes, lines etc. outside of any subclass and create a FuncAnimation that updates the lines.
Concerning the legend, it should be possible to blit that as well as long as it (a) is returned by the animating function, (b) spacially resides inside an axes.
Thank you for your reply! I've looked into FuncAnimation, but I didn't get it to work with pyQt.
ani = FuncAnimation(self.fig, self.animate, interval=50, blit=True)
The above line won't run the method self.animate(). No warnings/errors, it will just not enter that method.
Besides I've already have code that is implemented like the subclassed example above. Is there a way to blit: legend, xTicks and change ylimit inside the subclassed method def _draw_frame(self, framedata) aswell?
Activity
ImportanceOfBeingErnest commented on Jan 21, 2019
Worth noting that the example you refer to has been removed from the docs in #10125. The reason was
I think one would rather create the figure, axes, lines etc. outside of any subclass and create a FuncAnimation that updates the lines.
Concerning the legend, it should be possible to blit that as well as long as it (a) is returned by the animating function, (b) spacially resides inside an axes.
tkgit123 commented on Jan 22, 2019
Thank you for your reply! I've looked into FuncAnimation, but I didn't get it to work with pyQt.
ani = FuncAnimation(self.fig, self.animate, interval=50, blit=True)
The above line won't run the method self.animate(). No warnings/errors, it will just not enter that method.
Besides I've already have code that is implemented like the subclassed example above. Is there a way to blit: legend, xTicks and change ylimit inside the subclassed method def _draw_frame(self, framedata) aswell?
ImportanceOfBeingErnest commented on Jan 28, 2019
Usually that happens if ani gets garbage collected. Make sure you keep a reference to the FuncAnimation instance.
Once you start blitting everything, you may as well not blit at all. There will be no improvement in speed in such case.
jklymak commented on Oct 1, 2019
Closing as quite old, and I don't think there is an action here. Follow up on https://discourse.matplotlib.org if there is further discussion...