I tried the suggested clean-up but saw no difference in performance. I
left out a crucial piece of information, I think, in my earlier message.
The delay in drawing occurs when I'm running the code from within
ipython, invoked with the -pylab flag. When I run it directly from the
command line, I get no such delay. I presume this is backend dependent.
For my current purposes, just running it directly from the command line
(i.e. something like: % python do_fits.py) works for me. The ability to
interactively examine variables, as one can when running within ipython,
would be nicer, however.
Jon
···
On 06/24/2011 04:03 AM, Jonathan Slavin wrote:
> import matplotlib.pyplot as plt
> plt.ion()
> fig = plt.gcf()
> for obsid in obsids:
> <do fitting>
> plt.cla()
> fig = plt.gcf()
> ax = fig.add_axes([0.15,0.1,0.8,0.6])
> ax.plot(x,y)
> plt.draw()
> ans = raw_input('continue? ')
> if ans == 'n':
> break
The behavior may depend on mpl version and backend, but with
1.0.1 or
later, I think something like what you have will work with a
little
cleanup, e.g.:
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
fig = plt.gcf()
ax = fig.add_axes([0.15,0.1,0.8,0.6])
for i in range(3):
ax.cla()
ax.plot(np.random.rand(10))
plt.draw()
raw_input("hit a key to proceed")
Eric
I tried the suggested clean-up but saw no difference in performance. I
left out a crucial piece of information, I think, in my earlier message.
The delay in drawing occurs when I'm running the code from within
ipython, invoked with the -pylab flag. When I run it directly from the
command line, I get no such delay. I presume this is backend dependent.
For my current purposes, just running it directly from the command line
(i.e. something like: % python do_fits.py) works for me. The ability to
interactively examine variables, as one can when running within ipython,
would be nicer, however.
Jon
> import matplotlib.pyplot as plt
> plt.ion()
> fig = plt.gcf()
> for obsid in obsids:
> <do fitting>
> plt.cla()
> fig = plt.gcf()
> ax = fig.add_axes([0.15,0.1,0.8,0.6])
> ax.plot(x,y)
> plt.draw()
> ans = raw_input('continue? ')
> if ans == 'n':
> break
The behavior may depend on mpl version and backend, but with
1.0.1 or
later, I think something like what you have will work with a
little
cleanup, e.g.:
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
fig = plt.gcf()
ax = fig.add_axes([0.15,0.1,0.8,0.6])
for i in range(3):
ax.cla()
ax.plot(np.random.rand(10))
plt.draw()
raw_input("hit a key to proceed")
What happens if you replace the raw_input with the figure method waitforbuttonpress? (Also available as a pyplot function.)
Eric
···
On 06/27/2011 03:38 AM, Jonathan Slavin wrote:
On 06/24/2011 04:03 AM, Jonathan Slavin wrote:
Eric