Depending on the backend, you may be able to use
f = plt.figure()
f.canvas.flush_events()
Also, I would suggest to clear the image each time you go through the loop,
otherwise you'll end up with a huge number of images on top of each other.
Best,
-Michiel.
________________________________
From: zsero <zsolt....@gmail.com>
To: matplotlib-users@lists.sourceforge.net
Sent: Thursday, July 25, 2013 12:05 AM
Subject: [Matplotlib-users] How to update matplotlib's imshow() window
interactively?
I'm working on some computer vision algorithm and I'd like to show how a numpy
array changes in each step. What works now is that if I have a simple imshow(
array ) at the end of my code, the window displays and shows the final image.
However what I'd like to do is to update and display the imshow window as the
image changes in each iteration. So for example I'd like to do:
import numpy as np
import matplotlib.pyplot as plt
import time array = np.zeros( (100, 100), np.uint8 ) for i in xrange( 0, 100 ):
for j in xrange( 0, 50 ): array[j, i] = 1 #_show_updated_window_briefly_
plt.imshow( array ) time.sleep(0.1)
The problem is that this way, the Matplotlib window doesn't get activated, only
once the whole computation is finished. I've tried both native matplotlib and
pyplot, but the results are the same. For plotting commands I found an .ion()
switch, but here it doesn't seem to work. Q1. What is the best way to
continuously display updates to a numpy array (actually a uint8 greyscale
image)? Q2. Is it possible to do this with an animation function, like in the
dynamic image example? I'd like to call a function inside a loop, thus I don't
know how to achieve this with an animation function.
________________________________
View this message in context: How to update matplotlib's imshow() window
interactively?
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users