[Matplotlib-users] What is Artist._animated used for in Matplotlib

Thomas Caswell tcaswell at gmail.com
Mon Feb 6 16:03:47 EST 2017


See
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_base.py#L2355

It is used to exclude the 'animated' artists from the normal draw method
which greatly simplifies getting a clean background image.

Tom

On Mon, Feb 6, 2017 at 3:15 PM Yuri Sukhov <yuri.sukhov at gmail.com> wrote:

> Hi all,
>
> I am writing my own Animation class for Matplotlib in order to use
> event-based animation and it's unclear how Artist._animated and associated
> set_animated() function affect rendering.
>
> My animation should use blitting and I took existing FuncAnimation class
> as a reference for my implementation. In this class _init_draw and
> _draw_frame methods, among other things, set _animated = True for each
> artist in self._drawn_artists if blitting is enabled:
>
> for a in self._drawn_artists:
>     a.set_animated(self._blit)
>
> What is the reason for this operation? In what cases Artist._animated is
> used, and how it affects rendering with or without blitting? I have tested
> my implementation and I don't see any difference in behaviour with or
> without set_animated():
>
> class DataAnimation(Animation):
>     def __init__(self, fig, *args, **kwargs):
>         super(DataAnimation, self).__init__(fig,
> event_source=event_source, *args, **kwargs)
>
>     def new_frame_seq(self):
>         return itertools.count()
>
>     def _init_draw(self):
>         self._drawn_artists = plot.init()
>         for artist in self._drawn_artists:  # <- do we need this?
>             artist.set_animated(self._blit)
>
>     def _draw_frame(self, frame_data):
>         self._drawn_artists = plot.updated_artists
>         for artist in self._drawn_artists:  # <- do we need this?
>             artist.set_animated(self._blit)
>
> Thanks!
>
> Yuri.
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170206/2ac063dd/attachment.html>


More information about the Matplotlib-users mailing list