[IPython-User] matplotlib integration without pylab

David Warde-Farley wardefar@iro.umontreal...
Mon Mar 12 10:00:50 CDT 2012


On Sun, Mar 11, 2012 at 04:46:35PM -0400, Nikolaus Rath wrote:
> David Warde-Farley <wardefar@iro.umontreal.ca> writes:
> > On 2012-03-11, at 1:43 PM, Nikolaus Rath wrote:
> >
> >> Hello,
> >> 
> >> Is there a way to get --pylab style matplotlib integration (i.e., no
> >> need for blocking calls to matplotlib.pyplot.show() to display figures)
> >> without any of the other effects that come with --pylab? In particular,
> >> I do not want my namespace to be polluted with all the pylab commands.
> >
> > Use --gui=<backend>.
> 
> Have you tried that? It doesn't work here.
> 
> # ipython --gui=gtk
> Python 2.7.2+ (default, Nov 30 2011, 19:22:03) 
> Type "copyright", "credits" or "license" for more information.
> 
> IPython 0.12 -- An enhanced Interactive Python.
> 
> In [1]: from matplotlib import pyplot as plt
> 
> In [2]: import numpy as np
> 
> In [3]: plt.plot(np.arange(10), np.arange(10)**2)
> Out[3]: [<matplotlib.lines.Line2D at 0x2b28f90>]
> 
> [no windows shown ]
> 
> In [4]: plt.show()
> 
> [window visible, call blocks]

Calling pyplot.ion() before any of the other pyplot commands should do what
you want -- at least it does here with --gui=qt.

David


More information about the IPython-User mailing list