Restore_region not clearing plot area while using matplotlib

I’ve been using wxPython for a few weeks. As someone who hasn’t done GUI programming in almost 15 years, I love it. I’ve found the documentation to be great. There are a ton of great examples and skeleton applications. Combining wxPython with easy to use matplotlib has allowed me to quickly create a pretty good(by my standards anyway) control and real-time display application for some remote hardware. I’m at the point now where I’ve gone back to try and optimize the plotting functions to increase the frame rate. Seems many have the opinion that matplotlib has limited performance for real time plotting, but I’m trying to keep using it out of familiarity and ease of use.

That said, I’m having problems trying to use the restore_region and blit features. I tried to follow the example here, http://stackoverflow.com/questions/8955869/why-is-plotting-with-matplotlib-so-slow. Instead of restoring the background and plotting the new data set only, the new line is plotted over all previous runs. I’ve found similar issue here, http://stackoverflow.com/questions/4222344/clearing-background-in-matplotlib-using-wxpython but haven’t had any luck. I’ve also tried to use update() as recommended here - http://bastibe.de/2013-05-30-speeding-up-matplotlib.html with no success. In that case I get no plots unless I call draw() which I’m trying to avoid in the first place.

Anyway, I’ve boiled down the GUI to a simple example which I’ve attached. I’ve also attached a screen show of what pops up when it starts, and what it looks like after it runs multiple times. I’m running this on Windows 7, 64bit. wxPython version is 0.3.0.2.0, Python 2.7.8. Matplotlib 1.4.0. Any help or ideas would be appreciated.

testGUI_animate.py (3.52 KB)

afterrun.png

initial.png

I guess this is really a question for matplotlib folks, not wxpython. I updated to version 1.5.0 of matplotlib with the same issue. But I found this example of restore_background and blit that works. Very similar to my example code. https://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg04984.html. The difference was calling draw() and copy_from_bbox() AFTER calling self.Show. Sorry for the erroneous question.

···

On Sunday, January 10, 2016 at 2:37:40 AM UTC-5, Ovets wrote:

I’ve been using wxPython for a few weeks. As someone who hasn’t done GUI programming in almost 15 years, I love it. I’ve found the documentation to be great. There are a ton of great examples and skeleton applications. Combining wxPython with easy to use matplotlib has allowed me to quickly create a pretty good(by my standards anyway) control and real-time display application for some remote hardware. I’m at the point now where I’ve gone back to try and optimize the plotting functions to increase the frame rate. Seems many have the opinion that matplotlib has limited performance for real time plotting, but I’m trying to keep using it out of familiarity and ease of use.

That said, I’m having problems trying to use the restore_region and blit features. I tried to follow the example here, http://stackoverflow.com/questions/8955869/why-is-plotting-with-matplotlib-so-slow. Instead of restoring the background and plotting the new data set only, the new line is plotted over all previous runs. I’ve found similar issue here, http://stackoverflow.com/questions/4222344/clearing-background-in-matplotlib-using-wxpython but haven’t had any luck. I’ve also tried to use update() as recommended here - http://bastibe.de/2013-05-30-speeding-up-matplotlib.html with no success. In that case I get no plots unless I call draw() which I’m trying to avoid in the first place.

Anyway, I’ve boiled down the GUI to a simple example which I’ve attached. I’ve also attached a screen show of what pops up when it starts, and what it looks like after it runs multiple times. I’m running this on Windows 7, 64bit. wxPython version is 0.3.0.2.0, Python 2.7.8. Matplotlib 1.4.0. Any help or ideas would be appreciated.

Glad you got it figured out.

You might want to check out VisPy-- OpenGL based, so made for really fast interactive plotting.

And I’m pretty sure they’ve used a MPL - like API, so may be pretty easy to port.

Not sure if they’ve made it easy to embed in wx, but it’s certainly doable.

CHB

···

On Jan 10, 2016, at 11:56 AM, Ovets sph148@gmail.com wrote:

I guess this is really a question for matplotlib folks, not wxpython. I updated to version 1.5.0 of matplotlib with the same issue. But I found this example of restore_background and blit that works. Very similar to my example code. https://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg04984.html. The difference was calling draw() and copy_from_bbox() AFTER calling self.Show. Sorry for the erroneous question.

On Sunday, January 10, 2016 at 2:37:40 AM UTC-5, Ovets wrote:

I’ve been using wxPython for a few weeks. As someone who hasn’t done GUI programming in almost 15 years, I love it. I’ve found the documentation to be great. There are a ton of great examples and skeleton applications. Combining wxPython with easy to use matplotlib has allowed me to quickly create a pretty good(by my standards anyway) control and real-time display application for some remote hardware. I’m at the point now where I’ve gone back to try and optimize the plotting functions to increase the frame rate. Seems many have the opinion that matplotlib has limited performance for real time plotting, but I’m trying to keep using it out of familiarity and ease of use.

That said, I’m having problems trying to use the restore_region and blit features. I tried to follow the example here, http://stackoverflow.com/questions/8955869/why-is-plotting-with-matplotlib-so-slow. Instead of restoring the background and plotting the new data set only, the new line is plotted over all previous runs. I’ve found similar issue here, http://stackoverflow.com/questions/4222344/clearing-background-in-matplotlib-using-wxpython but haven’t had any luck. I’ve also tried to use update() as recommended here - http://bastibe.de/2013-05-30-speeding-up-matplotlib.html with no success. In that case I get no plots unless I call draw() which I’m trying to avoid in the first place.

Anyway, I’ve boiled down the GUI to a simple example which I’ve attached. I’ve also attached a screen show of what pops up when it starts, and what it looks like after it runs multiple times. I’m running this on Windows 7, 64bit. wxPython version is 0.3.0.2.0, Python 2.7.8. Matplotlib 1.4.0. Any help or ideas would be appreciated.

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 wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Thanks for the pointer! The example plots look really good. This is pretty far out of my wheelhouse so I’ll ask what I think is a basic question. Would something like this even work on a system without a dedicated GPU? And if so, would it still provide a significant performance boost over using mpl?

···

On Monday, January 11, 2016 at 11:26:25 AM UTC-5, Chris Barker - NOAA Federal wrote:

Glad you got it figured out.

You might want to check out VisPy-- OpenGL based, so made for really fast interactive plotting.

And I’m pretty sure they’ve used a MPL - like API, so may be pretty easy to port.

Not sure if they’ve made it easy to embed in wx, but it’s certainly doable.

CHB

On Jan 10, 2016, at 11:56 AM, Ovets sph...@gmail.com wrote:

I guess this is really a question for matplotlib folks, not wxpython. I updated to version 1.5.0 of matplotlib with the same issue. But I found this example of restore_background and blit that works. Very similar to my example code. https://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg04984.html. The difference was calling draw() and copy_from_bbox() AFTER calling self.Show. Sorry for the erroneous question.

On Sunday, January 10, 2016 at 2:37:40 AM UTC-5, Ovets wrote:

I’ve been using wxPython for a few weeks. As someone who hasn’t done GUI programming in almost 15 years, I love it. I’ve found the documentation to be great. There are a ton of great examples and skeleton applications. Combining wxPython with easy to use matplotlib has allowed me to quickly create a pretty good(by my standards anyway) control and real-time display application for some remote hardware. I’m at the point now where I’ve gone back to try and optimize the plotting functions to increase the frame rate. Seems many have the opinion that matplotlib has limited performance for real time plotting, but I’m trying to keep using it out of familiarity and ease of use.

That said, I’m having problems trying to use the restore_region and blit features. I tried to follow the example here, http://stackoverflow.com/questions/8955869/why-is-plotting-with-matplotlib-so-slow. Instead of restoring the background and plotting the new data set only, the new line is plotted over all previous runs. I’ve found similar issue here, http://stackoverflow.com/questions/4222344/clearing-background-in-matplotlib-using-wxpython but haven’t had any luck. I’ve also tried to use update() as recommended here - http://bastibe.de/2013-05-30-speeding-up-matplotlib.html with no success. In that case I get no plots unless I call draw() which I’m trying to avoid in the first place.

Anyway, I’ve boiled down the GUI to a simple example which I’ve attached. I’ve also attached a screen show of what pops up when it starts, and what it looks like after it runs multiple times. I’m running this on Windows 7, 64bit. wxPython version is 0.3.0.2.0, Python 2.7.8. Matplotlib 1.4.0. Any help or ideas would be appreciated.

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 wxpython-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Thanks for the pointer! The example plots look really good. This is
pretty far out of my wheelhouse so I'll ask what I think is a basic
question. Would something like this even work on a system without a
dedicated GPU?

probably -- there are pure-software OpenGL implementations, so common
systems support OpenGL, even if not fast. But I'd test for sure if you have
target systems in mind -- the VisPy folks are using "modern" OpenGL, so it
won't work on really old systems.

And if so, would it still provide a significant performance boost over
using mpl?

maybe, maybe not. if I had to guess, I'd think it might be faster, as MPL
does a lot of re-computing things it may not need to, but maybe not
"significant".

-CHB

···

On Mon, Jan 11, 2016 at 9:59 AM, Ovets <sph148@gmail.com> wrote:

On Monday, January 11, 2016 at 11:26:25 AM UTC-5, Chris Barker - NOAA > Federal wrote:

Glad you got it figured out.

You might want to check out VisPy-- OpenGL based, so made for really fast
interactive plotting.

And I'm pretty sure they've used a MPL - like API, so may be pretty easy
to port.

Not sure if they've made it easy to embed in wx, but it's certainly
doable.

CHB

On Jan 10, 2016, at 11:56 AM, Ovets <sph...@gmail.com> wrote:

I guess this is really a question for matplotlib folks, not wxpython. I
updated to version 1.5.0 of matplotlib with the same issue. But I found
this example of restore_background and blit that works. Very similar to my
example code.
Re: [matplotlib-devel] Bug with restore_background when mpl is embedded in wxpython.
  The difference was calling draw() and copy_from_bbox() AFTER calling
self.Show. Sorry for the erroneous question.

On Sunday, January 10, 2016 at 2:37:40 AM UTC-5, Ovets wrote:

I've been using wxPython for a few weeks. As someone who hasn't done
GUI programming in almost 15 years, I love it. I've found the
documentation to be great. There are a ton of great examples and skeleton
applications. Combining wxPython with easy to use matplotlib has allowed
me to quickly create a pretty good(by my standards anyway) control and
real-time display application for some remote hardware. I'm at the point
now where I've gone back to try and optimize the plotting functions to
increase the frame rate. Seems many have the opinion that matplotlib has
limited performance for real time plotting, but I'm trying to keep using it
out of familiarity and ease of use.

That said, I'm having problems trying to use the restore_region and blit
features. I tried to follow the example here,
python - why is plotting with Matplotlib so slow? - Stack Overflow.
Instead of restoring the background and plotting the new data set only, the
new line is plotted over all previous runs. I've found similar issue here,
python - Clearing background in matplotlib using wxPython - Stack Overflow
but haven't had any luck. I've also tried to use update() as recommended
here - Speeding up Matplotlib with no
success. In that case I get no plots unless I call draw() which I'm trying
to avoid in the first place.

Anyway, I've boiled down the GUI to a simple example which I've
attached. I've also attached a screen show of what pops up when it starts,
and what it looks like after it runs multiple times. I'm running this on
Windows 7, 64bit. wxPython version is 0.3.0.2.0, Python 2.7.8. Matplotlib
1.4.0. Any help or ideas would be appreciated.

--

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 wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

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 wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Thanks for the pointer! The example plots look really good. This is
pretty far out of my wheelhouse so I'll ask what I think is a basic
question. Would something like this even work on a system without a
dedicated GPU?

Oh, and no GPU is getting pretty rare these days, phones have them,
Raspberry Pi has one -- I think you'd be hard pressed to find a system
without one these days. on-board GPU would be fine -- you wouldn't need
some hard-core gaming system.

-CHB

···

On Mon, Jan 11, 2016 at 9:59 AM, Ovets <sph148@gmail.com> wrote:

probably -- there are pure-software OpenGL implementations, so common
systems support OpenGL, even if not fast. But I'd test for sure if you have
target systems in mind -- the VisPy folks are using "modern" OpenGL, so it
won't work on really old systems.

And if so, would it still provide a significant performance boost over
using mpl?

maybe, maybe not. if I had to guess, I'd think it might be faster, as MPL
does a lot of re-computing things it may not need to, but maybe not
"significant".

-CHB

On Monday, January 11, 2016 at 11:26:25 AM UTC-5, Chris Barker - NOAA >> Federal wrote:

Glad you got it figured out.

You might want to check out VisPy-- OpenGL based, so made for really
fast interactive plotting.

And I'm pretty sure they've used a MPL - like API, so may be pretty easy
to port.

Not sure if they've made it easy to embed in wx, but it's certainly
doable.

CHB

On Jan 10, 2016, at 11:56 AM, Ovets <sph...@gmail.com> wrote:

I guess this is really a question for matplotlib folks, not wxpython. I
updated to version 1.5.0 of matplotlib with the same issue. But I found
this example of restore_background and blit that works. Very similar to my
example code.
https://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg04984.html.
  The difference was calling draw() and copy_from_bbox() AFTER calling
self.Show. Sorry for the erroneous question.

On Sunday, January 10, 2016 at 2:37:40 AM UTC-5, Ovets wrote:

I've been using wxPython for a few weeks. As someone who hasn't done
GUI programming in almost 15 years, I love it. I've found the
documentation to be great. There are a ton of great examples and skeleton
applications. Combining wxPython with easy to use matplotlib has allowed
me to quickly create a pretty good(by my standards anyway) control and
real-time display application for some remote hardware. I'm at the point
now where I've gone back to try and optimize the plotting functions to
increase the frame rate. Seems many have the opinion that matplotlib has
limited performance for real time plotting, but I'm trying to keep using it
out of familiarity and ease of use.

That said, I'm having problems trying to use the restore_region and
blit features. I tried to follow the example here,
python - why is plotting with Matplotlib so slow? - Stack Overflow.
Instead of restoring the background and plotting the new data set only, the
new line is plotted over all previous runs. I've found similar issue here,
python - Clearing background in matplotlib using wxPython - Stack Overflow
but haven't had any luck. I've also tried to use update() as recommended
here - Speeding up Matplotlib with
no success. In that case I get no plots unless I call draw() which I'm
trying to avoid in the first place.

Anyway, I've boiled down the GUI to a simple example which I've
attached. I've also attached a screen show of what pops up when it starts,
and what it looks like after it runs multiple times. I'm running this on
Windows 7, 64bit. wxPython version is 0.3.0.2.0, Python 2.7.8. Matplotlib
1.4.0. Any help or ideas would be appreciated.

--

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 wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

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 wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Thanks again. I read OpenGL I thought of an external video card. Doing a little more reading I see what you mean, and the built in Intel HD Graphics processors support OpenGL. I’ll definitely take a look at this in the future if blitting with matplotlib is still a bottleneck.

···

On Monday, January 11, 2016 at 1:47:07 PM UTC-5, Chris Barker wrote:

On Mon, Jan 11, 2016 at 9:59 AM, Ovets sph...@gmail.com wrote:

Thanks for the pointer! The example plots look really good. This is pretty far out of my wheelhouse so I’ll ask what I think is a basic question. Would something like this even work on a system without a dedicated GPU?

Oh, and no GPU is getting pretty rare these days, phones have them, Raspberry Pi has one – I think you’d be hard pressed to find a system without one these days. on-board GPU would be fine – you wouldn’t need some hard-core gaming system.

-CHB

probably – there are pure-software OpenGL implementations, so common systems support OpenGL, even if not fast. But I’d test for sure if you have target systems in mind – the VisPy folks are using “modern” OpenGL, so it won’t work on really old systems.

And if so, would it still provide a significant performance boost over using mpl?

maybe, maybe not. if I had to guess, I’d think it might be faster, as MPL does a lot of re-computing things it may not need to, but maybe not “significant”.

-CHB

On Monday, January 11, 2016 at 11:26:25 AM UTC-5, Chris Barker - NOAA Federal wrote:

Glad you got it figured out.

You might want to check out VisPy-- OpenGL based, so made for really fast interactive plotting.

And I’m pretty sure they’ve used a MPL - like API, so may be pretty easy to port.

Not sure if they’ve made it easy to embed in wx, but it’s certainly doable.

CHB

On Jan 10, 2016, at 11:56 AM, Ovets sph...@gmail.com wrote:

I guess this is really a question for matplotlib folks, not wxpython. I updated to version 1.5.0 of matplotlib with the same issue. But I found this example of restore_background and blit that works. Very similar to my example code. https://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg04984.html. The difference was calling draw() and copy_from_bbox() AFTER calling self.Show. Sorry for the erroneous question.

On Sunday, January 10, 2016 at 2:37:40 AM UTC-5, Ovets wrote:

I’ve been using wxPython for a few weeks. As someone who hasn’t done GUI programming in almost 15 years, I love it. I’ve found the documentation to be great. There are a ton of great examples and skeleton applications. Combining wxPython with easy to use matplotlib has allowed me to quickly create a pretty good(by my standards anyway) control and real-time display application for some remote hardware. I’m at the point now where I’ve gone back to try and optimize the plotting functions to increase the frame rate. Seems many have the opinion that matplotlib has limited performance for real time plotting, but I’m trying to keep using it out of familiarity and ease of use.

That said, I’m having problems trying to use the restore_region and blit features. I tried to follow the example here, http://stackoverflow.com/questions/8955869/why-is-plotting-with-matplotlib-so-slow. Instead of restoring the background and plotting the new data set only, the new line is plotted over all previous runs. I’ve found similar issue here, http://stackoverflow.com/questions/4222344/clearing-background-in-matplotlib-using-wxpython but haven’t had any luck. I’ve also tried to use update() as recommended here - http://bastibe.de/2013-05-30-speeding-up-matplotlib.html with no success. In that case I get no plots unless I call draw() which I’m trying to avoid in the first place.

Anyway, I’ve boiled down the GUI to a simple example which I’ve attached. I’ve also attached a screen show of what pops up when it starts, and what it looks like after it runs multiple times. I’m running this on Windows 7, 64bit. wxPython version is 0.3.0.2.0, Python 2.7.8. Matplotlib 1.4.0. Any help or ideas would be appreciated.

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 wxpython-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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 wxpython-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris....@noaa.gov

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris....@noaa.gov