On Mon, Jun 18, 2012 at 3:36 AM, Maximilian Fabricius <mfabricius@gmail.com> wrote:
On Tue, Jun 12, 2012 at 6:40 PM, John Hunter <jdh2358@gmail.com> wrote:
> On Fri, Jun 8, 2012 at 3:36 AM, Maximilian Fabricius
> <mfabricius@gmail.com> wrote:
>> it seems that whenever I plot something, a window opens.
>> from matplotlib import pylab
>> import numpy
>> pylab.plot(numpy.random.normal(size=100))
>> Now, I have code that is supposed to produce diagnostic plots as PDFs. Only
> Before importing pylab, do
> import matplotlib
> matplotlib.use('pdf')
> The FAQ for using mpl in a web app server is pretty relevant to this use case
> http://matplotlib.sourceforge.net/faq/howto_faq.html#matplotlib-in-a-web-application-server

Hi John,

yes, I can do a matplotlib.use('pdf') (As a matter of fact I use this
as a workaround right now). But  I have to do this at the very
beginning of the code, i.e.
before the import of pyplot. Now, my routine has a --PLOT switch which
allows me to turn on the on-screen plotting.
Depending on that switch I now have to decide whether or not to call

This means that I have a lot of imports interspersed with other code
which looks terrible.

Really I am pretty sure that a simple script like:

from matplotlib import pyplot as pp

should not open a window. Only after a


the window should show up.

Note: I have tried to remove my .matplotlib directory. I have also checked

>>> pp.isinteractive()

Any help would be highly appreciated.



Did you check your ~/.matplotlib/matplotlibrc file like I suggested?  By default, these plots should not be coming up until you call show().  However, if "interactive" is set to True, then they will come up at the first plotting command.

Ben Root