Hallöchen!
John Hunter <jdhunter@...4...> writes:
> 2. The above loop is the last part of my program. The
> program terminates with> Fatal Python error: PyEval_RestoreThread: NULL
> tstate> Apparently, this is done by my improper handling of
> matplotlib. What's going wrong?This is an annoyance we haven't been able to get rid of in all use
cases. animation using pylab and tkagg is one of the places. I
assume you are using the tkagg backend?
Yes.
If you search the mailing list archives for PyEval_RestoreThread,
you'll see this in many contexts. For any semi-serious animation
work, I suggest you not use the matplotlib/interactive mode shown
in anim.py but rather use your GUI's idle handling or timer
mechanism as in examples/anim_tk.py or
examples/dyamic_image_gtkagg.py.
Thanks, I'll do.
[...]
> 3. How can I achieve that dynamic autoscaling of the
> y-axis? As noted in the source, "gcf().autoscale_view"
> has no effect.This is not legal matplotlib code -- I assume you mean
gca().autoscale_view().
Yes, sorry.
In the absence of more information it is hard top diagnose what
the problem is.
Here is a complete example:
···
#----------------------------------------------------------
from pylab import *
import time
ion()
cycles = 10
number_of_values = 100
total_number_values = 2 * cycles * number_of_values
x_values = arange(0, 2 * cycles, 1.0 / number_of_values)
y_values = total_number_values * [0.0]
line, = plot(x_values, y_values)
for i in range(2*cycles):
voltages = number_of_values * [i % 2 + 3]
y_values[i * number_of_values : (i+1) * number_of_values] = \
voltages
line.set_ydata(y_values)
gca().autoscale_view()
draw()
time.sleep(1)
#----------------------------------------------------------
Here, no autoscaling happens.
Tschö,
Torsten.
--
Torsten Bronger, aquisgrana, europa vetus