<div dir="ltr"><a href="http://www.aosabook.org/en/matplotlib.html">http://www.aosabook.org/en/matplotlib.html</a> is a reasonable starting point, it refers to 0.96, but the core of the library has not changed much.<br><div><br></div><div>The very short version is that through a layer or two of in-direction when the figure is rendered, the canvas creates a renderer and pass it to `Figure.draw` which then recurses it's children calling `Artist.draw` which renders all of the artists to the canvas (which may represent a file or a bit map, which in the case of a GUI is then passed to the GUI toolkit and displayed on the screen).</div><div><br></div><div>`draw_artist` is a helper-method on Axes to make doing blitting work easier.  During `Axes.draw` it caches a reference to the renderer so that you can out-of-band render additional artists.  See <a href="http://matplotlib.org/api/animation_api.html#funcanimation">http://matplotlib.org/api/animation_api.html#funcanimation</a> for a much longer explanation of how this works.</div><div><br></div><div>Tom</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Feb 7, 2017 at 2:16 PM Yuri Sukhov <<a href="mailto:yuri.sukhov@gmail.com">yuri.sukhov@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Thomas,<br class="gmail_msg">
<br class="gmail_msg">
Thank you for your response. Is it possible to find somewhere<br class="gmail_msg">
documentation with the details on how drawing is done in Matplotlib?<br class="gmail_msg">
Or maybe you can shed some light on this? Of course source code is<br class="gmail_msg">
here and I am reading it, but without knowing of what are the major<br class="gmail_msg">
steps of the process, it takes a lot of time to take all parts<br class="gmail_msg">
together.<br class="gmail_msg">
<br class="gmail_msg">
I looked at the _AxesBase.draw() method, and I can see that, if<br class="gmail_msg">
_animated is set for the artist, than it's excluded from rasterization<br class="gmail_msg">
(not sure if that is the right term). That does not tell me much,<br class="gmail_msg">
because I am not aware of the whole drawing process. I am not even<br class="gmail_msg">
sure, when is this draw() method called? It seems to me that<br class="gmail_msg">
_blit_draw() from Animation class calls a.axes.draw_artist(a), but<br class="gmail_msg">
that is a different method and it does not check _animation property<br class="gmail_msg">
for the artist.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
On Mon, Feb 6, 2017 at 11:03 PM, Thomas Caswell <<a href="mailto:tcaswell@gmail.com" class="gmail_msg" target="_blank">tcaswell@gmail.com</a>> wrote:<br class="gmail_msg">
> See<br class="gmail_msg">
> <a href="https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_base.py#L2355" rel="noreferrer" class="gmail_msg" target="_blank">https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_base.py#L2355</a><br class="gmail_msg">
><br class="gmail_msg">
> It is used to exclude the 'animated' artists from the normal draw method<br class="gmail_msg">
> which greatly simplifies getting a clean background image.<br class="gmail_msg">
><br class="gmail_msg">
> Tom<br class="gmail_msg">
><br class="gmail_msg">
> On Mon, Feb 6, 2017 at 3:15 PM Yuri Sukhov <<a href="mailto:yuri.sukhov@gmail.com" class="gmail_msg" target="_blank">yuri.sukhov@gmail.com</a>> wrote:<br class="gmail_msg">
>><br class="gmail_msg">
>> Hi all,<br class="gmail_msg">
>><br class="gmail_msg">
>> I am writing my own Animation class for Matplotlib in order to use<br class="gmail_msg">
>> event-based animation and it's unclear how Artist._animated and associated<br class="gmail_msg">
>> set_animated() function affect rendering.<br class="gmail_msg">
>><br class="gmail_msg">
>> My animation should use blitting and I took existing FuncAnimation class<br class="gmail_msg">
>> as a reference for my implementation. In this class _init_draw and<br class="gmail_msg">
>> _draw_frame methods, among other things, set _animated = True for each<br class="gmail_msg">
>> artist in self._drawn_artists if blitting is enabled:<br class="gmail_msg">
>><br class="gmail_msg">
>> for a in self._drawn_artists:<br class="gmail_msg">
>>     a.set_animated(self._blit)<br class="gmail_msg">
>><br class="gmail_msg">
>> What is the reason for this operation? In what cases Artist._animated is<br class="gmail_msg">
>> used, and how it affects rendering with or without blitting? I have tested<br class="gmail_msg">
>> my implementation and I don't see any difference in behaviour with or<br class="gmail_msg">
>> without set_animated():<br class="gmail_msg">
>><br class="gmail_msg">
>> class DataAnimation(Animation):<br class="gmail_msg">
>>     def __init__(self, fig, *args, **kwargs):<br class="gmail_msg">
>>         super(DataAnimation, self).__init__(fig,<br class="gmail_msg">
>> event_source=event_source, *args, **kwargs)<br class="gmail_msg">
>><br class="gmail_msg">
>>     def new_frame_seq(self):<br class="gmail_msg">
>>         return itertools.count()<br class="gmail_msg">
>><br class="gmail_msg">
>>     def _init_draw(self):<br class="gmail_msg">
>>         self._drawn_artists = plot.init()<br class="gmail_msg">
>>         for artist in self._drawn_artists:  # <- do we need this?<br class="gmail_msg">
>>             artist.set_animated(self._blit)<br class="gmail_msg">
>><br class="gmail_msg">
>>     def _draw_frame(self, frame_data):<br class="gmail_msg">
>>         self._drawn_artists = plot.updated_artists<br class="gmail_msg">
>>         for artist in self._drawn_artists:  # <- do we need this?<br class="gmail_msg">
>>             artist.set_animated(self._blit)<br class="gmail_msg">
>><br class="gmail_msg">
>> Thanks!<br class="gmail_msg">
>><br class="gmail_msg">
>> Yuri.<br class="gmail_msg">
>> _______________________________________________<br class="gmail_msg">
>> Matplotlib-users mailing list<br class="gmail_msg">
>> <a href="mailto:Matplotlib-users@python.org" class="gmail_msg" target="_blank">Matplotlib-users@python.org</a><br class="gmail_msg">
>> <a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" class="gmail_msg" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br class="gmail_msg">
</blockquote></div>