The following trivial program is supposed to generate one plot per key press
until the user presses 'q'. Instead, nothing is displayed until the user
presses 'q'. Any suggestions will be appreciated.
from os import sys
from matplotlib import *
from numpy.random import rand
while True:
z=
Try something like this:
from os import sys
from matplotlib import *
from numpy.random import rand
fig= pyplot.figure(figsize=(8,8), dpi=120)
pyplot.show()
while True:
z= rand(20,20)
pyplot.imshow(z)
pyplot.draw()
chr= sys.stdin.read(1)
if chr=='q':
break
appologies - sys.stdin.read(1) blocks until you give it a new line
(Enter) that' s probably what you were having problems with.
Paul Ivanov, on 2009-08-23 01:14, wrote:
Try something like this:
from os import sys
from matplotlib import *
from numpy.random import rand
fig=
Having to hit Enter is not a major problem, but I'm still not getting
anything displayed.
I noticed that you used pyplot.draw() instead of pyplot.show(). I've
checked the available documentation, but haven't been able to understand the
difference between these.
I should have mentioned that I'm
Dr. Phillip M. Feldman wrote:
Having to hit Enter is not a major problem, but I'm still not getting
anything displayed.
i guess that might be because the show command before the loop blocks
the program.
you can omit the line with show or start ipython with
ipython -pylab
both versions work