[Matplotlib-users] Efficiency in connecting two subplot.

Thomas Caswell tcaswell at gmail.com
Sat Mar 3 12:16:20 EST 2018


It looks like you are redrawing the _whole_ figure every time.

You can use blitting (see
https://matplotlib.org/api/animation_api.html#funcanimation for details) to
only re-draw the axes that is changing.

Tom

On Tue, Feb 20, 2018 at 3:28 PM Benjamin Root <ben.v.root at gmail.com> wrote:

> Yup, that's pretty much it. Since you have it all in a class, then doing
> `self.counter` makes a lot of sense. You can also tune it accordingly to do
> only every 3rd, 4th, 5th or what-have-you.
>
> Cheers!
> Ben Root
>
> On Tue, Feb 20, 2018 at 3:03 PM, Christophe Bal <projetmbc at gmail.com>
> wrote:
>
>> Thanks
>>
>> Christophe BAL
>> Enseignant Agrégé de Mathématiques
>> Programmeur Python Amateur
>>
>> Le 20 févr. 2018 20:02, "Éric Depagne" <eric at depagne.org> a écrit :
>>
>>> Hi Christophe,
>>>
>>> I am not sure it's what Ben had in mind (if not, I'm happy to know  how
>>> it
>>> should have been done), but here is the way I did it.
>>>
>>> (my _on_move() method is a member of a class)
>>> I added this to the __init__() :
>>> self.counter = 0
>>>
>>> Then I added the following lines to _on_move():
>>> self.counter += 1
>>> if self.counter %2 :
>>>         return
>>> [snip all the details of the update of the plots)
>>> self.counter = 0
>>>
>>> And it updates the plot every other move.
>>>
>>> Éric.
>>>
>>> --
>>> Un clavier azerty en vaut deux
>>> ----------------------------------------------------------
>>> Éric Depagne
>>>
>>>
>>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users at python.org
>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>
>>
> _______________________________________________
> 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/20180303/66e7067a/attachment.html>


More information about the Matplotlib-users mailing list