I'm wrecked

I’m not sure if this is a matplotlib issue or what, but all of a sudden I was not able to do gca() or gcf() correctly.

A simple command-line on pyshell (using wxAgg backend) went like this:

import pylab
pylab.plot([1,2,1]) # figure pops up
pylab.gca().clear(); pylab.show() # nothing happens
pylab.gcf().clear(); pylab.show() # nothing happens
pylab.clf() # works fine

I’ve played with getting the current figure, storing it in a temporary variable a, trying “a.clear()” trying any manipulations and they don’t work. It’s like the figures/axes returned by gca() and gcf() no longer correspond to the only open figure I can see.

I don’t have time to figure it out (I have a paper due and I’ve already thrown 3 hours at figuring out why my scripts aren’t working), and I know there’s an outside chance it’s all my fault. I’ve uninstalled everything and I’m putting enthought on (older matplotlib). Anyway, I’m sorry if this turns out to be my fault, but can anyone test/confirm/deny this behavior? I was using the latest mpl 0.98.3 and python 2.5.

Thanks,
-Jack

Jack Sankey wrote:

I'm not sure if this is a matplotlib issue or what, but all of a sudden I was not able to do gca() or gcf() correctly.

A simple command-line on pyshell (using wxAgg backend) went like this:

I'm not familiar with pyshell, but evidently it is turning interactive mode on, correct?

import pylab
pylab.plot([1,2,1]) # figure pops up
pylab.gca().clear(); pylab.show() # nothing happens

Why are you doing this? In interactive mode, you should not be calling show() at all. And, you are mixing pylab and OO interfaces in a strange way; if you want to work interactively via the pylab interface, you should use pylab.cla() and pylab.clf(). If you want to work interactively but *mostly* with the OO interface, then you can call axes methods like clear(), but you need to put in pylab.draw() when you want the figure redrawn.

pylab.gcf().clear(); pylab.show() # nothing happens

With interactive mode off, in a script, show() should never be called more than once; it should be the last plot-related line of the script.

pylab.clf() # works fine

because it is internally calling pylab.draw_if_interactive().

Eric

···

I've played with getting the current figure, storing it in a temporary variable a, trying "a.clear()" trying any manipulations and they don't work. It's like the figures/axes returned by gca() and gcf() no longer correspond to the only open figure I can see.

I don't have time to figure it out (I have a paper due and I've already thrown 3 hours at figuring out why my scripts aren't working), and I know there's an outside chance it's all my fault. I've uninstalled everything and I'm putting enthought on (older matplotlib). Anyway, I'm sorry if this turns out to be my fault, but can anyone test/confirm/deny this behavior? I was using the latest mpl 0.98.3 and python 2.5.

Thanks,
-Jack

------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks Eric,

I may be doing things a little bit weird since I’ve been with matplotlib for many years. I did two things that fixed my problem: I wiped python25 out completely and install enthought (with an older pylab). During the wipe I noticed an extra pythonw running in the task manager that I had to kill. It may be that this thing was a corrupted version of wx running in the background, messing everything up. I may try reinstalling at a later date to see.

I’m not familiar with pyshell, but evidently it is turning interactive mode on, correct?

I am turning interactive mode on.

import pylab

pylab.plot([1,2,1]) # figure pops up

pylab.gca().clear(); pylab.show() # nothing happens

Why are you doing this? In interactive mode, you should not be calling show() at all. And, you are mixing pylab and OO interfaces in a strange way; if you want to work interactively via the pylab interface, you should use pylab.cla() and pylab.clf(). If you want to work interactively but mostly with the OO interface, then you can call axes methods like clear(), but you need to put in pylab.draw() when you want the figure redrawn.

hmm. I know at one point I was doing a window Refresh() which was slow. Then I discovered pylab.show() which drastically sped up my plotting (I made a program that modifies colorbars in real time and this really helped). Maybe the next and final step is “pylab.draw()”? :slight_smile: Sorry if my code is hacky. I figure most of my stuff out using pyshell’s autocomplete to play.

Incidentally, since these commands work fine.

Thanks again! (now back to work for me)

-Jack

I thought we supported repeated calls to show. Some people use multiple show
calls in order to step through a number of plots in a script.

···

On Thursday 21 August 2008 17:36:50 Eric Firing wrote:

Jack Sankey wrote:
> pylab.gcf().clear(); pylab.show() # nothing happens

With interactive mode off, in a script, show() should never be called
more than once; it should be the last plot-related line of the script.

My impression has always been that calling show() more than once is bad and not supported.

Ryan

···

On Thu, Aug 21, 2008 at 4:58 PM, Darren Dale <dsdale24@…287…> wrote:

On Thursday 21 August 2008 17:36:50 Eric Firing wrote:> Jack Sankey wrote:

pylab.gcf().clear(); pylab.show() # nothing happens

With interactive mode off, in a script, show() should never be called

more than once; it should be the last plot-related line of the script.

I thought we supported repeated calls to show. Some people use multiple show

calls in order to step through a number of plots in a script.


Ryan May

Graduate Research Assistant
School of Meteorology
University of Oklahoma

well it hasn’t caused me any crashes yet so far as I can tell. Other naughty things I do cause crashes, though.

···

On Thu, Aug 21, 2008 at 8:03 PM, Ryan May <rmay31@…287…> wrote:

On Thu, Aug 21, 2008 at 4:58 PM, Darren Dale <dsdale24@…287…> wrote:

On Thursday 21 August 2008 17:36:50 Eric Firing wrote:> Jack Sankey wrote:

pylab.gcf().clear(); pylab.show() # nothing happens

With interactive mode off, in a script, show() should never be called

more than once; it should be the last plot-related line of the script.

I thought we supported repeated calls to show. Some people use multiple show

calls in order to step through a number of plots in a script.

My impression has always been that calling show() more than once is bad and not supported.

Ryan


Ryan May

Graduate Research Assistant
School of Meteorology
University of Oklahoma