where did my plots go?

Hi All,

I have mac os x, 10.6.8, enthought distribution.

I recently upgraded from the 6.2 to 7.3 EPD.

Previously, I had a script which would manipulate some data, and as soon as the command

plt.figure()

was issued, the plot would show up. I could then continue along with the analysis (I wrote an interactive script) and plots would be updated, and new plots would show up (when I issued a command like re-sizing the plot limits.

This no longer happens, and now the plots are not drawn until the very end of all the analysis. But of course this defeats the purpose of having an interactive analysis session.

I do have plt.show() at the very end of the script.
In case it may matter, my main script loads another one as a module. (But this is how it was before when it worked).

I am not sure what has caused this to change. I have tried the follwing

- restart computer in case there were just some gui problem
- re-install the EPD 7.3 and EPD 6.2 (in that order)
- use the older 6.2 installation to run the script

all of these fail to produce the behavior I previously had. It would be great to sort this out.

Thanks,

Andre

Most likely, there was a change to your matplotlibrc file. There is a setting in there for “interactive” and by default, it is set to False. If you uncomment it and set it to True, you should get back the behavior you expected. You can also explicitly set the interactive mode to True from your scripts with a “plt.ion()” call before loading your other modules.

I hope that helps!
Ben Root

···

On Mon, Jun 18, 2012 at 2:36 AM, Andre’ Walker-Loud <walksloud@…287…> wrote:

Hi All,

I have mac os x, 10.6.8, enthought distribution.

I recently upgraded from the 6.2 to 7.3 EPD.

Previously, I had a script which would manipulate some data, and as soon as the command

plt.figure()

was issued, the plot would show up. I could then continue along with the analysis (I wrote an interactive script) and plots would be updated, and new plots would show up (when I issued a command like re-sizing the plot limits.

This no longer happens, and now the plots are not drawn until the very end of all the analysis. But of course this defeats the purpose of having an interactive analysis session.

I do have plt.show() at the very end of the script.

In case it may matter, my main script loads another one as a module. (But this is how it was before when it worked).

I am not sure what has caused this to change. I have tried the follwing

  • restart computer in case there were just some gui problem

  • re-install the EPD 7.3 and EPD 6.2 (in that order)

  • use the older 6.2 installation to run the script

all of these fail to produce the behavior I previously had. It would be great to sort this out.

Thanks,

Andre

Most likely, there was a change to your matplotlibrc file. There is a setting in there for "interactive" and by default, it is set to False. If you uncomment it and set it to True, you should get back the behavior you expected. You can also explicitly set the interactive mode to True from your scripts with a "plt.ion()" call before loading your other modules.

I hope that helps!

Yes!!!

I don't recall changing that before (but that was 2+ years ago), so I didn't think to look for such a thing.
My google searches were also not precise enough.
So very helpful. I expected it was something simple like this, thanks.

Andre

Hi All,

Sort of hijacking my own thread here. I posted another issue yesterday or the day before, and this has caused me to find some bigger problems...

Most likely, there was a change to your matplotlibrc file. There is a setting in there for "interactive" and by default, it is set to False. If you uncomment it and set it to True, you should get back the behavior you expected. You can also explicitly set the interactive mode to True from your scripts with a "plt.ion()" call before loading your other modules.

I was having such problems with my setup (mac os 10.6.8, EPD 7.3[ python2.7 matplotlib 1.1.0]), I decided to completely wipe all my python installations in

/Library/Frameworks/Python.framework/Versions/

I then re-installed EPD 7.3
I modified my matplotlibrc to
backend : TkAgg
interactive : True

I have run with --verbose-helpful to verify that these options are used (at least at startup).
But my plots still vanish as soon as the script is done :`( [that is me, a grown man, crying]

I see I can use matplotlib.pyplot.isinteractive() to see that interactive is true.
How can I print the rc param to check the backend? I haven't found this on google or in the matplotlib userguide yet.

Also, any ideas? I am pulling hair out since of course I am supposed to be doing analysis for a talk next monday.

Thanks,

Andre

2012/6/19 Andre' Walker-Loud <walksloud@...287...>:

But my plots still vanish as soon as the script is done :

That's to be expected. You can make the script not to end until the
user ask for it explicitly:

raw_input('Press <Enter> when you are done')

Goyo

Hi Goyo,

2012/6/19 Andre' Walker-Loud <walksloud@...287...>:

But my plots still vanish as soon as the script is done :

That's to be expected. You can make the script not to end until the
user ask for it explicitly:

raw_input('Press <Enter> when you are done')

If this is expected - it is a new feature.

My understanding was that changing

interactive : True

in the matplotlibrc file, then the plots would not vanish until explicitly closed by the user.

Is my understanding incorrect?

Thanks,

Andre

That is correct. If you have a call to show(), then the script should not finish on their own until the windows are closed – regardless of whether or not “interactive” is True or False. The “interactive” setting should only dictate whether or not the script execution pauses or not at the call to show(). Have you tried a different backend as a temporary work-around such as QTAgg, QT4Agg, GTKAgg, TkAgg?

Ben Root

···

On Tue, Jun 19, 2012 at 2:40 PM, Andre’ Walker-Loud <walksloud@…287…> wrote:

Hi Goyo,

2012/6/19 Andre’ Walker-Loud <walksloud@…287…>:

But my plots still vanish as soon as the script is done :

That’s to be expected. You can make the script not to end until the

user ask for it explicitly:

raw_input(‘Press when you are done’)

If this is expected - it is a new feature.

My understanding was that changing

interactive : True

in the matplotlibrc file, then the plots would not vanish until explicitly closed by the user.

Is my understanding incorrect?

Thanks,

Andre

Hi Ben,

···

On Jun 19, 2012, at 12:15 PM, Benjamin Root wrote:
On Tue, Jun 19, 2012 at 2:40 PM, Andre' Walker-Loud <walksloud@...287...> wrote:
Hi Goyo,

> 2012/6/19 Andre' Walker-Loud <walksloud@...287...>:
>> But my plots still vanish as soon as the script is done :
>
> That's to be expected. You can make the script not to end until the
> user ask for it explicitly:
>
> raw_input('Press <Enter> when you are done')

If this is expected - it is a new feature.

My understanding was that changing

interactive : True

in the matplotlibrc file, then the plots would not vanish until explicitly closed by the user.

Is my understanding incorrect?

Thanks,

Andre

That is correct. If you have a call to show(), then the script should not finish on their own until the windows are closed -- regardless of whether or not "interactive" is True or False. The "interactive" setting should only dictate whether or not the script execution pauses or not at the call to show(). Have you tried a different backend as a temporary work-around such as QTAgg, QT4Agg, GTKAgg, TkAgg?

This behavior is observed with both TkAgg and MacOSX.
I don't have pygtk or pyqt installed, so couldn't test the others.

Andre

If this is expected - it is a new feature.

My understanding was that changing

interactive : True

in the matplotlibrc file, then the plots would not vanish until explicitly closed by the user.

Is my understanding incorrect?

Thanks,

Andre

That is correct. If you have a call to show(), then the script should not finish on their own until the windows are closed -- regardless of whether or not "interactive" is True or False. The "interactive" setting should only dictate whether or not the script execution pauses or not at the call to show(). Have you tried a different backend as a temporary work-around such as QTAgg, QT4Agg, GTKAgg, TkAgg?

This behavior is observed with both TkAgg and MacOSX.
I don't have pygtk or pyqt installed, so couldn't test the others.

In case it matters, I am using the i386 installation and not the x86_64.

I have more info - which may be helpful.

Inspired by a related thread - which Goyo just answered, I tried the following

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

In an interactive python session (also in ipython), this produced the plot, and it stayed up until I closed it.

I converted it to a little script

···

===
#!/Library/Frameworks/Python.framework/Versions/Current/bin/python

import matplotlib.pyplot as plt
plt.plot([1.6, 2.7])
print plt.get_backend()

plt.show()

this prints to screen "TkAgg", but the plot disappears as soon as the script finishes.

Thanks,
Andre

2012/6/19 Benjamin Root <ben.root@...1304...>:

Hi Goyo,

> 2012/6/19 Andre' Walker-Loud <walksloud@...287...>:
>> But my plots still vanish as soon as the script is done :
>
> That's to be expected. You can make the script not to end until the
> user ask for it explicitly:
>
> raw_input('Press <Enter> when you are done')

If this is expected - it is a new feature.

My understanding was that changing

interactive : True

in the matplotlibrc file, then the plots would not vanish until explicitly
closed by the user.

Is my understanding incorrect?

Thanks,

Andre

That is correct. If you have a call to show(), then the script should not
finish on their own until the windows are closed -- regardless of whether or
not "interactive" is True or False. The "interactive" setting should only
dictate whether or not the script execution pauses or not at the call to
show().

Then the script is supposed to keep itself alive, after executing the
last statment, until the plot windows are closed? Does not work that
way for me (tkagg, qt4agg and gtk*) and I wouldn't expect that.

BTW this may be better than using raw_input:

import matplotlib.pyplot as plt
plt.ion()
plt.plot([1.6, 2.7]) # The plot windows shows up.
# Do stuff, even user interaction, more plots, etc.
# ...
# Wait until all plot windows are closed.
plt.ioff()
plt.show()

Goyo

···

On Tue, Jun 19, 2012 at 2:40 PM, Andre' Walker-Loud <walksloud@...287...> > wrote:

Hi Goyo,

That is correct. If you have a call to show(), then the script should not
finish on their own until the windows are closed -- regardless of whether or
not "interactive" is True or False. The "interactive" setting should only
dictate whether or not the script execution pauses or not at the call to
show().

Then the script is supposed to keep itself alive, after executing the
last statment, until the plot windows are closed? Does not work that
way for me (tkagg, qt4agg and gtk*) and I wouldn't expect that.

Yes, this is how things used to work on my mac (1 week ago). After upgrade, no longer works this way. Reverting to old compilation - still no longer works.

BTW this may be better than using raw_input:

import matplotlib.pyplot as plt
plt.ion()
plt.plot([1.6, 2.7]) # The plot windows shows up.
# Do stuff, even user interaction, more plots, etc.
# ...
# Wait until all plot windows are closed.
plt.ioff()
plt.show()

This reproduces (as far as I can tell) the exact behavior I used to have.

Interesting to note. If I have "interactive : True" in my matplotlibrc file, and then

import matplotlib.pyplot as plt
# do everything I used to do
# including call functions that do other plots etc.

plt.ioff()
plt.show()

this also produces the above behavior (what used to work).

So, if I am in interactive mode, then matplotlibrc opens and closes the figures for me. However, if after making all my plots, just before calling plt.show(), I turn off interactive mode, then the plots stay open.

This does not follow the logic I would expect - ie interactive means I would have to close the figures interactively. But it gives the behavior I have come to expect.

Now back to my other problems (I'll start a new thread).

Cheers,

Andre