suppress plotting window

Hi all,

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
when I pass a command line option the script should actually open a
window and also display
the results on the screen.

I am pretty sure that in earlier times the window would only open when
I call pylab.show().

It may well be that I messed too much with my matplotlibrc, if you
could just point me in the right direction ...

I use matplotlib 1.0.1 on a Mac with the MacOSX backend.

Maximilian

You should see if you accidentially turned on the interactive mode. Just make sure that the “interactive” setting is set to False.

Ben Root

···

On Fri, Jun 8, 2012 at 4:36 AM, Maximilian Fabricius <mfabricius@…287…> wrote:

Hi all,

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

when I pass a command line option the script should actually open a

window and also display

the results on the screen.

I am pretty sure that in earlier times the window would only open when

I call pylab.show().

It may well be that I messed too much with my matplotlibrc, if you

could just point me in the right direction …

I use matplotlib 1.0.1 on a Mac with the MacOSX backend.

Maximilian

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

···

On Fri, Jun 8, 2012 at 3:36 AM, Maximilian Fabricius <mfabricius@...287...> 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

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

···

On Tue, Jun 12, 2012 at 6:40 PM, John Hunter <jdh2358@...287...> wrote:

On Fri, Jun 8, 2012 at 3:36 AM, Maximilian Fabricius > <mfabricius@...287...> wrote:

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

···

On Mon, Jun 18, 2012 at 3:36 AM, Maximilian Fabricius <mfabricius@…287…> wrote:

On Tue, Jun 12, 2012 at 6:40 PM, John Hunter <jdh2358@…287…> wrote:

On Fri, Jun 8, 2012 at 3:36 AM, Maximilian Fabricius > > > <mfabricius@…287…> 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

Hi Ben,

yes, it is not enabled. Also a call to pyplot.isinteractive() returns False.

Maximilian

···

On Mon, Jun 18, 2012 at 3:02 PM, Benjamin Root <ben.root@...1304...> wrote:

On Mon, Jun 18, 2012 at 3:36 AM, Maximilian Fabricius <mfabricius@...985.....> > wrote:

On Tue, Jun 12, 2012 at 6:40 PM, John Hunter <jdh2358@...287...> wrote:
> On Fri, Jun 8, 2012 at 3:36 AM, Maximilian Fabricius >> > <mfabricius@...287...> 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

--
--------------------------------------------------------------------
Maximilian Fabricius
* Max Planck Institute for Extraterrestrial Physics (MPE)
Giessenbachstrasse, D-85748 Garching, Germany
* University Observatory Munich / Wendelstein Observatory
Scheinerstr. 1, D-81679 München, Germany
eMail: mxhf@...2911...
Phone: +49 89 30000 3779
--------------------------------------------------------------------

2012/6/8 Maximilian Fabricius <mfabricius@...287...>:

···

Hi all,

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
when I pass a command line option the script should actually open a
window and also display
the results on the screen.

I am pretty sure that in earlier times the window would only open when
I call pylab.show().

It may well be that I messed too much with my matplotlibrc, if you
could just point me in the right direction ...

I use matplotlib 1.0.1 on a Mac with the MacOSX backend.

From http://matplotlib.sourceforge.net/faq/usage_faq.html#non-interactive-example:

----------------------------------------------------------
import matplotlib.pyplot as plt
plt.ioff()
plt.plot([1.6, 2.7])

Nothing happened–or at least nothing has shown up on the screen
(unless you are using macosx backend, which is anomalous).
----------------------------------------------------------

Goyo

Hi Goyo,

I see! I am using the macosx backend. That was the hint I needed. Thanks a lot!

Maximilian

···

On Tue, Jun 19, 2012 at 9:27 PM, Goyo <goyodiaz@...287...> wrote:

2012/6/8 Maximilian Fabricius <mfabricius@...287...>:

Hi all,

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
when I pass a command line option the script should actually open a
window and also display
the results on the screen.

I am pretty sure that in earlier times the window would only open when
I call pylab.show().

It may well be that I messed too much with my matplotlibrc, if you
could just point me in the right direction ...

I use matplotlib 1.0.1 on a Mac with the MacOSX backend.

From http://matplotlib.sourceforge.net/faq/usage_faq.html#non-interactive-example:

----------------------------------------------------------
import matplotlib.pyplot as plt
plt.ioff()
plt.plot([1.6, 2.7])

Nothing happened–or at least nothing has shown up on the screen
(unless you are using macosx backend, which is anomalous).
----------------------------------------------------------

Goyo

--
--------------------------------------------------------------------
Maximilian Fabricius
* Max Planck Institute for Extraterrestrial Physics (MPE)
Giessenbachstrasse, D-85748 Garching, Germany
* University Observatory Munich / Wendelstein Observatory
Scheinerstr. 1, D-81679 München, Germany
eMail: mxhf@...2911...
Phone: +49 89 30000 3779
--------------------------------------------------------------------