matplotlib basic question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • orangeDinosaur

    matplotlib basic question

    Hi,

    I am exploring the possibility of using python as a replacement of
    MATLAB when I leave school. So, I've been playing with matplotlib and
    have run into some weird behavior after recently installing python
    2.5.1 and matplotlib 0.90 on my Windows XP machine. Here's an example
    of what I see:
    >>>from matplotlib.pyla b import *
    >>>x=arange(-2*pi,2*pi,pi/24)
    >>>y=sin(x)
    >>>plot(x,y)
    [<matplotlib.lin es.Line2D instance at 0x017C38C8>]
    >>show()

    So, first off, what's up with the [<matplotlib.lin es.Line2D instance
    at 0x017C38C8>] line that shows up after my plot command? And second,
    when I call show(), a new figure pops up with my sin wave -- seems all
    right, yes? But I'm not given another >>prompt in IDLE until or
    unless I close the figure that popped up with the show() call.

    So, after closing the figure I type this:
    >>>show()
    >>>plot(x,y)
    >>>
    and this time another figure pops up with my sine wave again and I get
    a prompt as well. But now, the figure window is completely
    unresponsive -- I can't even close it without getting the "your
    program is not repsonding" business. What am I missing? This
    behavior so far seems pretty unintuitive.

    Any clarification is appreciated!

    trevis

  • cfriedalek@gmail.com

    #2
    Re: matplotlib basic question

    So, first off, what's up with the [<matplotlib.lin es.Line2D instance
    at 0x017C38C8>] line that shows up after my plot command? And second,
    when I call show(), a new figure pops up with my sin wave -- seems all
    right, yes? But I'm not given another >>prompt in IDLE until or
    unless I close the figure that popped up with the show() call.
    This may not be strictly correct but thats a reference to the plot
    instance which is subsequently passed to show().
    If you don't want to see it put a semicolon at the end of your command
    eg. plot(range(5));

    The issue with IDLE is to due with lack of connection between the
    python interpreter event loop and the event loop of matplotlib (I
    think). For me the solution was to install the ipython shell (http://
    ipython.scipy.o rg/moin/). If you run ipython with the -pylab flag then
    you can matplotlib interactively. For example

    plot(range(5),' bo')
    show()
    clf()
    plot([1,2,3,4,5],range(0,10,2), 'r-')
    (no need for another show() command since the graphics display is
    already visible ... unless of course I deleted it in between plot
    commands)

    hth


    Comment

    • Rob Clewley

      #3
      Re: matplotlib basic question

      On 19 Apr 2007 16:13:43 -0700, cfriedalek@gmai l.com
      <cfriedalek@gma il.comwrote:
      >
      So, first off, what's up with the [<matplotlib.lin es.Line2D instance
      at 0x017C38C8>] line that shows up after my plot command? And second,
      when I call show(), a new figure pops up with my sin wave -- seems all
      right, yes? But I'm not given another >>prompt in IDLE until or
      unless I close the figure that popped up with the show() call.
      This may not be strictly correct but thats a reference to the plot
      instance which is subsequently passed to show().
      If you don't want to see it put a semicolon at the end of your command
      eg. plot(range(5));
      My understanding is that the semicolon trick is specific to IPython,
      and does not work in IDLE. I don't know about in other environments.
      You can just assign the list of returned plot objects to a variable to
      make it invisible at the command line although these return values
      (like all return values) are not "shown in the command window" (i.e.
      passed to stdout) if they are returned from calls made in a script.
      The issue with IDLE is to due with lack of connection between the
      python interpreter event loop and the event loop of matplotlib (I
      think). For me the solution was to install the ipython shell (http://
      ipython.scipy.o rg/moin/). If you run ipython with the -pylab flag then
      you can matplotlib interactively. For example
      >
      plot(range(5),' bo')
      show()
      clf()
      plot([1,2,3,4,5],range(0,10,2), 'r-')
      (no need for another show() command since the graphics display is
      already visible ... unless of course I deleted it in between plot
      commands)
      The OP appears to be using IDLE, for which the things to try are:

      In site-packages/matplotlib/backends/backend_tkagg.p y uncomment the
      line #os.environ['PYTHONINSPECT'] = '1'

      Set interactive=Tru e in share/matplotlib/.matplotlibrc

      Start IDLE with the -n flag

      In site-packages/matplotlib/backends/backend_tkagg.p y comment out the line

      Tk.mainloop()

      in the function "show"

      -Rob

      Comment

      • Colin J. Williams

        #4
        Re: matplotlib basic question

        orangeDinosaur wrote:
        Hi,
        >
        I am exploring the possibility of using python as a replacement of
        MATLAB when I leave school. So, I've been playing with matplotlib and
        have run into some weird behavior after recently installing python
        2.5.1 and matplotlib 0.90 on my Windows XP machine. Here's an example
        of what I see:
        >
        >>from matplotlib.pyla b import *
        >>>x=arange(-2*pi,2*pi,pi/24)
        >>>y=sin(x)
        >>>plot(x,y)
        [<matplotlib.lin es.Line2D instance at 0x017C38C8>]
        >>>show()
        >
        >
        So, first off, what's up with the [<matplotlib.lin es.Line2D instance
        at 0x017C38C8>] line that shows up after my plot command? And second,
        when I call show(), a new figure pops up with my sin wave -- seems all
        right, yes? But I'm not given another >>prompt in IDLE until or
        unless I close the figure that popped up with the show() call.
        >
        So, after closing the figure I type this:
        >
        >>>show()
        >>>plot(x,y)
        >>>>
        >
        and this time another figure pops up with my sine wave again and I get
        a prompt as well. But now, the figure window is completely
        unresponsive -- I can't even close it without getting the "your
        program is not repsonding" business. What am I missing? This
        behavior so far seems pretty unintuitive.
        >
        Any clarification is appreciated!
        >
        trevis
        >
        Trevis,

        You might look at Numpy, which deals with multi-dimensional arrays.

        It has a small matrix component and some progress has been made with
        MATLAB amenable problems.

        Colin W.

        Comment

        • Pete Forman

          #5
          Re: matplotlib basic question

          orangeDinosaur <trevis.crane@g mail.comwrites:
          [...] But now, the figure window is completely unresponsive -- I
          can't even close it without getting the "your program is not
          repsonding" business. What am I missing? This behavior so far
          seems pretty unintuitive.
          The best way out of this is to use IPython. It also needs a backend
          which remains responsive, WxAgg works but Tk did not last time I
          tried. IPython 0.8.1 is a release candidate which fixes some Windows
          issues in 0.8.0. If you want a stable package that has all the parts
          present out of the box then look at Enthought.
          --
          Pete Forman -./\.- Disclaimer: This post is originated
          WesternGeco -./\.- by myself and does not represent
          pete.forman@wes terngeco.com -./\.- the opinion of Schlumberger or
          http://petef.port5.com -./\.- WesternGeco.

          Comment

          • orangeDinosaur

            #6
            Re: matplotlib basic question

            OK, I'll go with the enthought installation. This seems to be the
            path of least resistance. For those of you who have been in my
            position, is there a reason NOT to go with the enthought installation
            and do things piecemeal instead?

            thanks,
            trevis

            On Apr 20, 11:36 am, Pete Forman <pete.for...@we sterngeco.comwr ote:
            orangeDinosaur <trevis.cr...@g mail.comwrites:
            >
            [...] But now, the figure window is completely unresponsive -- I
            can't even close it without getting the "your program is not
            repsonding" business. What am I missing? This behavior so far
            seems pretty unintuitive.
            >
            The best way out of this is to use IPython. It also needs a backend
            which remains responsive, WxAgg works but Tk did not last time I
            tried. IPython 0.8.1 is a release candidate which fixes some Windows
            issues in 0.8.0. If you want a stable package that has all the parts
            present out of the box then look at Enthought.
            --
            Pete Forman -./\.- Disclaimer: This post is originated
            WesternGeco -./\.- by myself and does not represent
            pete.for...@wes terngeco.com -./\.- the opinion of Schlumberger orhttp://petef.port5.com -./\.- WesternGeco.

            Comment

            • Colin J. Williams

              #7
              Re: matplotlib basic question

              orangeDinosaur wrote:
              OK, I'll go with the enthought installation. This seems to be the
              path of least resistance. For those of you who have been in my
              position, is there a reason NOT to go with the enthought installation
              and do things piecemeal instead?
              >
              thanks,
              trevis
              >
              On Apr 20, 11:36 am, Pete Forman <pete.for...@we sterngeco.comwr ote:
              >orangeDinosa ur <trevis.cr...@g mail.comwrites:
              >>
              > [...] But now, the figure window is completely unresponsive -- I
              > can't even close it without getting the "your program is not
              > repsonding" business. What am I missing? This behavior so far
              > seems pretty unintuitive.
              >>
              >The best way out of this is to use IPython. It also needs a backend
              >which remains responsive, WxAgg works but Tk did not last time I
              >tried. IPython 0.8.1 is a release candidate which fixes some Windows
              >issues in 0.8.0. If you want a stable package that has all the parts
              >present out of the box then look at Enthought.
              >--
              >Pete Forman -./\.- Disclaimer: This post is originated
              >WesternGeco -./\.- by myself and does not represent
              >pete.for...@we sterngeco.com -./\.- the opinion of Schlumberger orhttp://petef.port5.com -./\.- WesternGeco.
              >
              >
              It's rather heavy and may include stuff you don't need.

              I'm not sure that scipy has been updated to Python 2.5

              Colin W.

              Comment

              • Robert Kern

                #8
                Re: matplotlib basic question

                Colin J. Williams wrote:
                I'm not sure that scipy has been updated to Python 2.5
                ? scipy certainly works with 2.5. Are you referring to something else perhaps?

                --
                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

                Comment

                • Tommy Grav

                  #9
                  Re: matplotlib basic question

                  On Apr 20, 2007, at 2:44 PM, Robert Kern wrote:
                  Colin J. Williams wrote:
                  >
                  >I'm not sure that scipy has been updated to Python 2.5
                  >
                  ? scipy certainly works with 2.5. Are you referring to something
                  else perhaps?
                  A side question: Is there any plans of updating the scipy.org
                  Superpack bundle
                  for Mac OS X to work with 2.5?

                  Cheers
                  Tommy

                  Comment

                  • Robert Kern

                    #10
                    Re: matplotlib basic question

                    Tommy Grav wrote:
                    On Apr 20, 2007, at 2:44 PM, Robert Kern wrote:
                    >Colin J. Williams wrote:
                    >>
                    >>I'm not sure that scipy has been updated to Python 2.5
                    >? scipy certainly works with 2.5. Are you referring to something
                    >else perhaps?
                    >
                    A side question: Is there any plans of updating the scipy.org
                    Superpack bundle
                    for Mac OS X to work with 2.5?
                    You would have to ask Chris Fonnesbeck. It's not an "official" binary inasmuch
                    as scipy has official binaries.

                    --
                    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

                    Comment

                    • Tommy Grav

                      #11
                      Re: matplotlib basic question

                      On Apr 20, 2007, at 3:49 PM, Robert Kern wrote:
                      Tommy Grav wrote:
                      >On Apr 20, 2007, at 2:44 PM, Robert Kern wrote:
                      >>Colin J. Williams wrote:
                      >>>
                      >>>I'm not sure that scipy has been updated to Python 2.5
                      >>? scipy certainly works with 2.5. Are you referring to something
                      >>else perhaps?
                      >>
                      >A side question: Is there any plans of updating the scipy.org
                      >Superpack bundle
                      >for Mac OS X to work with 2.5?
                      >
                      You would have to ask Chris Fonnesbeck. It's not an "official"
                      binary inasmuch
                      as scipy has official binaries.
                      Okidoki. This is the last reason for me not upgrading to 2.5 as I
                      have a hard
                      time compiling things from scratch :)

                      Cheers
                      Tommy

                      Comment

                      • Pete Forman

                        #12
                        Re: matplotlib basic question

                        Robert Kern <robert.kern@gm ail.comwrites:
                        Colin J. Williams wrote:
                        >
                        >I'm not sure that scipy has been updated to Python 2.5
                        >
                        ? scipy certainly works with 2.5. Are you referring to something
                        else perhaps?
                        Yes, the Python Enthought Edition was being discussed and it is
                        currently based on Python 2.4.3.


                        --
                        Pete Forman -./\.- Disclaimer: This post is originated
                        WesternGeco -./\.- by myself and does not represent
                        pete.forman@wes terngeco.com -./\.- the opinion of Schlumberger or
                        http://petef.port5.com -./\.- WesternGeco.

                        Comment

                        • Robert Kern

                          #13
                          Re: matplotlib basic question

                          Pete Forman wrote:
                          Robert Kern <robert.kern@gm ail.comwrites:
                          >
                          Colin J. Williams wrote:
                          >>I'm not sure that scipy has been updated to Python 2.5
                          ? scipy certainly works with 2.5. Are you referring to something
                          else perhaps?
                          >
                          Yes, the Python Enthought Edition was being discussed and it is
                          currently based on Python 2.4.3.
                          >
                          http://code.enthought.com/enthon/
                          I'm quite familiar with Python Enthought Edition as I work at Enthought. I was
                          confused because Colin referenced scipy specifically rather than simply saying
                          that the current version of Python Enthought Edition was not based on 2.5.

                          --
                          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

                          Comment

                          Working...