python v ipython problem in imshow()

I'm using the following code to plot some grided data

        fig1=pylab.figure()
        contents1=fig1.add_subplot(111)
        stuff=contents1.imshow(mydata,origin='lower',aspect='equal')

and I find that if I launch the code with 'ipython' the data looks as expected but if I use 'python' then the x-axis annotations are OK but the data is still plotted with the origin in the top left hand corner. I'm using the enthought 6.1 distribution and the version of matplotlib and pylab imported in both cases is the same. I guess one indicator of a major difference is that ipython has the icon bar for the plot at the bottom of the screen but python has the icon bar at the top of the screen. Any clues ... I'd happily just use ipython but I distribute the code to others so I'd like to get it sorted.

Sounds like a backend problem (see
http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend
and http://matplotlib.sourceforge.net/users/customizing.html)

First thing you'll want to do is put

import matplotlib
print matplotlib.rcParams['backend']

at the top of your script and run it in both environments and report
what you find. My guess is one of the environments has a backend that
does not support the image origin argument.

JDH

···

On Tue, Nov 9, 2010 at 4:33 PM, Garry Willgoose <Garry.Willgoose@...3343...> wrote:

I'm using the following code to plot some grided data

   fig1=pylab\.figure\(\)
   contents1=fig1\.add\_subplot\(111\)
   stuff=contents1\.imshow\(mydata,origin=&#39;lower&#39;,aspect=&#39;equal&#39;\)

and I find that if I launch the code with 'ipython' the data looks as expected but if I use 'python' then the x-axis annotations are OK but the data is still plotted with the origin in the top left hand corner. I'm using the enthought 6.1 distribution and the version of matplotlib and pylab imported in both cases is the same. I guess one indicator of a major difference is that ipython has the icon bar for the plot at the bottom of the screen but python has the icon bar at the top of the screen. Any clues ... I'd happily just use ipython but I distribute the code to others so I'd like to get it sorted.

John,

OK by looking at matplotlib.rcParams['backend'] I've been able to diagnose this a little more.

When the backend is 'WXAgg' everything looks fine. The axes have (0,0) where you would expect and the data is plotted correctly.

However, when the backend is 'MacOSX' the axes again have (0,0) where you would expect but the data is plotted so it is flipped vertically (i.e. what is at the top is at the bottom, and vice versa).

It doesn't look like an issue between python and ipython, or at least I don't seem to have been able to reproduce it tonight

I'm using matplotlib version 0.99.1.1. Is this likely to be fixed in V1.0? I haven't upgraded to the latest enthought distribution because I had some problems with the binary extension libraries I have written ... I ought to sort it out but I've got a bit of deadline approaching and I'd prefer to leave it til later

···

On Tue, Nov 9, 2010 at 4:33 PM, Garry Willgoose > <Garry.Willgoose@...3343...> wrote:

I'm using the following code to plot some grided data

       fig1=pylab.figure()
       contents1=fig1.add_subplot(111)
       stuff=contents1.imshow(mydata,origin='lower',aspect='equal')

and I find that if I launch the code with 'ipython' the data looks as expected but if I use 'python' then the x-axis annotations are OK but the data is still plotted with the origin in the top left hand corner. I'm using the enthought 6.1 distribution and the version of matplotlib and pylab imported in both cases is the same. I guess one indicator of a major difference is that ipython has the icon bar for the plot at the bottom of the screen but python has the icon bar at the top of the screen. Any clues ... I'd happily just use ipython but I distribute the code to others so I'd like to get it sorted.

Sounds like a backend problem (see
http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend
and http://matplotlib.sourceforge.net/users/customizing.html)

First thing you'll want to do is put

import matplotlib
print matplotlib.rcParams['backend']

at the top of your script and run it in both environments and report
what you find. My guess is one of the environments has a backend that
does not support the image origin argument.

JDH

It looks like the macosx backend has not implemented support for the
image origin parameter. I'm CC-ing Michiel, the macosx author, to see
if this is something he can add support for.

Thanks,
JDH

···

On Wed, Nov 10, 2010 at 5:43 AM, Garry Willgoose <Garry.Willgoose@...3343...> wrote:

John,

OK by looking at matplotlib.rcParams['backend'] I've been able to diagnose this a little more.

When the backend is 'WXAgg' everything looks fine. The axes have (0,0) where you would expect and the data is plotted correctly.

However, when the backend is 'MacOSX' the axes again have (0,0) where you would expect but the data is plotted so it is flipped vertically (i.e. what is at the top is at the bottom, and vice versa).

It doesn't look like an issue between python and ipython, or at least I don't seem to have been able to reproduce it tonight

I'm using matplotlib version 0.99.1.1. Is this likely to be fixed in V1.0? I haven't upgraded to the latest enthought distribution because I had some problems with the binary extension libraries I have written ... I ought to sort it out but I've got a bit of deadline approaching and I'd prefer to leave it til later

Garry, if the bug still exists in matplotlib 1.0 could you open a bug report for it?

Thanks,
--Michiel.

···

--- On Wed, 11/10/10, John Hunter <jdh2358@...287...> wrote:

From: John Hunter <jdh2358@...287...>
Subject: Re: [Matplotlib-users] python v ipython problem in imshow()
To: "Garry Willgoose" <Garry.Willgoose@...3343...>, "Michiel de Hoon" <mjldehoon@...9...>
Cc: matplotlib-users@lists.sourceforge.net
Date: Wednesday, November 10, 2010, 8:28 AM
On Wed, Nov 10, 2010 at 5:43 AM, > Garry Willgoose > <Garry.Willgoose@...3343...> > wrote:
> John,
>
> OK by looking at matplotlib.rcParams['backend'] I've
been able to diagnose this a little more.
>
> When the backend is 'WXAgg' everything looks fine.
The axes have (0,0) where you would expect and the data is
plotted correctly.
>
> However, when the backend is 'MacOSX' the axes again
have (0,0) where you would expect but the data is plotted so
it is flipped vertically (i.e. what is at the top is at the
bottom, and vice versa).
>
> It doesn't look like an issue between python and
ipython, or at least I don't seem to have been able to
reproduce it tonight
>
> I'm using matplotlib version 0.99.1.1. Is this likely
to be fixed in V1.0? I haven't upgraded to the latest
enthought distribution because I had some problems with the
binary extension libraries I have written ... I ought to
sort it out but I've got a bit of deadline approaching and
I'd prefer to leave it til later

It looks like the macosx backend has not implemented
support for the
image origin parameter. I'm CC-ing Michiel, the
macosx author, to see
if this is something he can add support for.

Thanks,
JDH

I think Gary doesn't have easy access to 1.0. Here is the relevant
example if anyone has 1.0 on macosx to test with

  http://matplotlib.sourceforge.net/examples/pylab_examples/image_origin.html

JDH

···

On Wed, Nov 10, 2010 at 9:48 AM, Michiel de Hoon <mjldehoon@...9...> wrote:

Garry, if the bug still exists in matplotlib 1.0 could you open a bug report for it?

I haven't been able to replicate this bug. With all matplotlib versions
I tried (including 0.99.0, 0.99.1., 0.99.1.1, 0.99.1.2, 1.0.0, and the current source code in svn), this example works correctly with the Mac OS X backend.
Garry, what is the exact code that you are using?

--Michiel.

···

--- On Wed, 11/10/10, John Hunter <jdh2358@...287...> wrote:

From: John Hunter <jdh2358@...287...>
Subject: Re: [Matplotlib-users] python v ipython problem in imshow()
To: "Michiel de Hoon" <mjldehoon@...9...>
Cc: "Garry Willgoose" <Garry.Willgoose@...3343...>, matplotlib-users@...1867...s.sourceforge.net
Date: Wednesday, November 10, 2010, 10:59 AM
On Wed, Nov 10, 2010 at 9:48 AM, > Michiel de Hoon <mjldehoon@...9...> > wrote:
> Garry, if the bug still exists in matplotlib 1.0 could
you open a bug report for it?

I think Gary doesn't have easy access to 1.0. Here is
the relevant
example if anyone has 1.0 on macosx to test with

http://matplotlib.sourceforge.net/examples/pylab_examples/image_origin.html

JDH