matplotlib basic question

Rob Clewley rhc28 at cornell.edu
Thu Apr 19 22:52:10 EDT 2007


On 19 Apr 2007 16:13:43 -0700, cfriedalek at gmail.com
<cfriedalek at gmail.com> wrote:
>
> > So, first off, what's up with the [<matplotlib.lines.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.org/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.py uncomment the
line #os.environ['PYTHONINSPECT'] = '1'

Set interactive=True in share/matplotlib/.matplotlibrc

Start IDLE with the -n flag

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

  Tk.mainloop()

in the function "show"

-Rob



More information about the Python-list mailing list