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

R

Ravikanth

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()'
 
R

Robert Kern

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.

Please use the matplotlib-users list for matplotlib questions. By the way, four
versions of your message made it to this list. I'm sure the repetition was an
honest mistake, but there may be things you can do to prevent it in the future.

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

To answer your question, you are probably using an older version of matplotlib
than 1.0.0. The ability to use show() more than once was only added in 1.0.0:

http://matplotlib.sourceforge.net/faq/howto_faq.html#use-show

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
R

Ravikanth

Please use the matplotlib-users list for matplotlib questions. By the way, four
versions of your message made it to this list. I'm sure the repetition was an
honest mistake, but there may be things you can do to prevent it in the future.

   https://lists.sourceforge.net/lists/listinfo/matplotlib-users

To answer your question, you are probably using an older version of matplotlib
than 1.0.0. The ability to use show() more than once was only added in 1.0.0:

   http://matplotlib.sourceforge.net/faq/howto_faq.html#use-show

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

Hi Robert,


Thank you for the link.

I did not see my post posted onto the groups after i sent my query,
which usually does happen in a few minutes. So I thought i posted it
wrongly and reposted it. My apologies for inconvenience.
I'll make sure this does not repeat.


Regards,
Ravikanth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top