show() in pylab doesn't work if used twice

Ravikanth vvnrk.vanapalli at gmail.com
Wed Jul 6 18:05:48 EDT 2011


Hi all,

I have been using python for just over a month now.
I am writing a program to plot some graph using the  show() twice in
the same program. The code snippet is shown below.
I am trying to plot a simple x vs y using ax.plot() then I get a
figure displayed. I close the figure displayed and then the execution
proceeds. Now If i try to call show second time with the updated
values of x and y, the second figure does not appear on my desktop.
but the second call to show() appears to work as the code also printed
'passed the second show' as well
Can someone help me figure out what the problem  here is.why is the
second figure not coming up on the desktop.

I am using python 2.7 .




from pylab import *
import scipy
import pylab as pl
import matplotlib.pyplot as plt
fig=pl.figure()
ax=fig.add_subplot(111)
x=arange(10)
y=x*2
ax.plot(x,y)
show()


print 'passed the first show()'
x=arange(10)
y=sin(x)
ax.plot(x,y)
show()
print 'passed the second show()'



More information about the Python-list mailing list