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


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
matplotlib.use('pdf').

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
pp.plot([1,2,3])

should not open a window. Only after a

pp.show()

the window should show up.

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

>>> pp.isinteractive()
False

Any help would be highly appreciated.

Maximilian


Maxmillian,

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.

Cheers!
Ben Root