[IPython-user] matplotlibrc and ipython -pylab

John Hunter jdh2358@gmail....
Sun Jul 27 22:01:27 CDT 2008


On Sun, Jul 27, 2008 at 6:59 PM, Johann Cohen-Tanugi
<cohen@slac.stanford.edu> wrote:
> Hi,
> I have a .matplotlib directory where matplotlibrc has GTKAgg as a
> default backend, for my everyday use. But I am also developing an
> ipython-base framework for other users in my collaboration, with a
> custom python/ipython install which does not include pygtk. So I would
> like to be be able to tell ipython/pylab to look somewhere else for the
> correct matplotlibrc, or to not read it at all....
> How can I do that?
> ipython -pylab does a  lot before I can call rc in my modules, so I need
> something upstream from my code.

You can place your rc file in an arbitrary location and point to it by
setting your MATPLOTLIBRC environment variable.  You may be interested
to know that Gael recently patched matplotlib to support a
'backend_fallback' rc param.  This new rc param was motivated in large
part to support ipython frontend developers (and users) as well as
others who want to use mpl in embedded apps.

The way it works is, if you set this variable to True, the matplotlib
will use your backend setting *unless* pyplot/pylab finds itself in an
already running gui mainloop, in which case it will set the backend to
something sensible depending on which mainloop is running.  Suppose
you love GTKAgg on a daily basis, but are developing or using a qt
frontend for ipython in some special purpose app.  Set your backend to
'GTKAgg' and set backend_fallback to True.  When you import
pylab/pyplot from your qt app, matplotlib will detect that qt is
imported and the mainloop is running, and will fallback on qtagg.

This exists currently only in mpl svn, but will be out in the next release soon.

JDH


More information about the IPython-user mailing list