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

Discussion in 'Python' started by Ravikanth, Jul 6, 2011.

  1. Ravikanth

    Ravikanth Guest

    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()'
     
    Ravikanth, Jul 6, 2011
    #1
    1. Advertising

  2. Ravikanth

    Robert Kern Guest

    On 7/6/11 5:05 PM, Ravikanth wrote:
    > 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
     
    Robert Kern, Jul 7, 2011
    #2
    1. Advertising

  3. Ravikanth

    Ravikanth Guest

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

    On Jul 6, 6:26 pm, Robert Kern <> wrote:
    > On 7/6/11 5:05 PM, Ravikanth wrote:
    >
    > > 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


    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
     
    Ravikanth, Jul 7, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    523
    Istvan Albert
    Jan 19, 2005
  2. Dr. Colombes
    Replies:
    3
    Views:
    668
    John Hunter
    Feb 23, 2005
  3. Replies:
    0
    Views:
    329
  4. timw.google

    pylab doesn't find numpy on Windows

    timw.google, Jun 13, 2006, in forum: Python
    Replies:
    2
    Views:
    638
    timw.google
    Jun 13, 2006
  5. Kiuhnm

    twice(twice(x))

    Kiuhnm, Apr 1, 2006, in forum: C++
    Replies:
    2
    Views:
    397
    Kiuhnm
    Apr 1, 2006
Loading...

Share This Page