[Matplotlib-users] Why is flush_events() taking longer than expected?

David Aldrich David.Aldrich at EMEA.NEC.COM
Tue Jul 25 10:49:37 EDT 2017


Hi Ben

>When you say first and second flush_events(), do you mean the
>first and second iterations, or fig_A and fig_B?

The latter:

    fig_A.canvas.flush_events()     <-- 350ms
    fig_B.canvas.flush_events()     <-- 1ms

These timings repeat on each iteration.

Best regards

David

From: Benjamin Root [mailto:ben.v.root at gmail.com]
Sent: 25 July 2017 15:46
To: David Aldrich <David.Aldrich at EMEA.NEC.COM>
Cc: matplotlib-users at python.org
Subject: Re: [Matplotlib-users] Why is flush_events() taking longer than expected?

When you say first and second flush_events(), do you mean the first and second iterations, or fig_A and fig_B?
Ben Root

On Fri, Jul 21, 2017 at 9:33 AM, David Aldrich <David.Aldrich at emea.nec.com<mailto:David.Aldrich at emea.nec.com>> wrote:
Hi

I am using Matplotlib 2.0.2 in a Python 3.6 script on Windows 10 to plot data received over a network connection. New data arrives 4 times per second. I need to update two figures fig_A and fig_B, each containing 8 subplots. The hardware is a fast i7 laptop.

My main execution loop is:

plt.draw()

while (True):
    fig_A.canvas.flush_events()
    fig_B.canvas.flush_events()
    updatePlots()                          # Polls socket for data and updates scatter collections
    fig_A.canvas.draw_idle()
    fig_B.canvas.draw_idle()

plt.waitforbuttonpress()

I have timed the code and found that the first flush_events() call in the loop takes 350ms. The second flush_events() call takes <1ms.
350ms seems very long and is restricting the update rate.

Why might flush_events() be taking so long?

(I have not changed the backend from the default, which I believe is TkAgg).

Best regards

David

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org<mailto:Matplotlib-users at python.org>
https://mail.python.org/mailman/listinfo/matplotlib-users



Click here<https://www.mailcontrol.com/sr/HdU0jnqYd33GX2PQPOmvUiOFufhVdryLTKI5fnw3hQXAeY!z4oAmQUowjoeq+mdHW6eN7GuMFmZOzrnJmt4uGw==> to report this email as spam.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170725/c6902ebc/attachment.html>


More information about the Matplotlib-users mailing list