Re: Plotting to a matplotlib / pyplot window does not work

Matt Newville <[email protected]>
Newsgroups gmane.comp.python.wxpython
Message-ID <CA+7ESbqATRriLNLxxmu6j4S8n7posbH=um_L_TkMkpBNZjeJdQ@mail.gmail.com>
Hi Matthias,

On Thu, Jul 23, 2020 at 7:55 AM Matthias Brennwald <[email protected]>
wrote:

> On Do, Jul 23, 2020 at 13:46, Andrea Gavana <[email protected]>
> wrote:
>
> If the plotting part is relatively quick, there shouldn't be any pile-up
> of events, unless the rate of data coming in from your instrument exceeds
> the FPS of your plotting. At that point the GUI is busy plotting stuff
> only, which is not good. If you have a very high rate of wx.CallAfter stuff
> coming in, then I suggest you update the plot every N times instead of
> every time something comes in.
>
>
> Yeah, this is essentially what I am doing, see the example I attached in
> my earlier post. However, I had to make some glue code that prevents the
> wx.CallAfter calls from piling up (sorry, I mixed up CallAfter and
> CallLater in my previous post). I wonder if there is a way to avoid this
> glue code by using some mechanism or approach that is "built in" wxPython.
>
> On Do, Jul 23, 2020 at 07:15, Matt Newville <[email protected]>
> wrote:
>
> One alternative would be to use a simple Timer that calls a function to
> "fetch the latest data and display it".   That can then run at the natural
> rate for your GUI client to fetch the data and render that display.   This
> approach allows the GUI to be responsive, and not miss any data even if it
> does not update exactly once for every single data event.  It also gives
> you a convenient method to temporarily pause the display (just have access
> to the Timer's stop() and start() methods).
>
>
> This sounds like a great idea! This would allow the plot windows to deal
> with the updating on their own, so the thread dealing with the getting the
> data from the instrument does not need to care about the plots. I have no
> clue about Timers, though... can you point me in the right direction?
>

An example using a Timer for plotting is at:

https://github.com/newville/wxmplot/blob/master/examples/stripchart.py

>
the data generation there is deliberately simple but should give the basic
idea.

--Matt

-- 
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/CA%2B7ESbqATRriLNLxxmu6j4S8n7posbH%3Dum_L_TkMkpBNZjeJdQ%40mail.gmail.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.