imshow and projections

I've been playing with some of the projections in matplotlib,
recently, and have some questions/noticed some odd behavior:

1. Is there any way to activate a projection mode with the pyplot
interface other than the subplot(111,projection='whatever') method a
la /examples/api/custom_projection_example.py ? Along these same
lines, is the projection feature documented in greater detail
somewhere? About everything I've figured out has come from
custom_projection_example.py ...

2. I have a skymap I would like to plot using a particular projection
- what I've been doing so far is specifying x and y coordinates using
mgrid and calling contourf(x,y,data,100) to approximate this. But
what I'd rather do is something like
imshow(data,extent=[-pi,pi,-pi/2,pi/2]) ... when I call that with a
projection axis activated, the projection isn't honored - the image
just appears as a regular square box. Is there any way to get imshow
to respect the projection?

2. I have a skymap I would like to plot using a particular projection
- what I've been doing so far is specifying x and y coordinates using
mgrid and calling contourf(x,y,data,100) to approximate this. But
what I'd rather do is something like
imshow(data,extent=[-pi,pi,-pi/2,pi/2]) ... when I call that with a
projection axis activated, the projection isn't honored - the image
just appears as a regular square box. Is there any way to get imshow
to respect the projection?

Did you try pcolormesh (or pcolor)? I believe these commands respect
the projection.

pcolormesh(x, y, data)

-JJ

Erik Tollerud wrote:

I've been playing with some of the projections in matplotlib,
recently, and have some questions/noticed some odd behavior:

1. Is there any way to activate a projection mode with the pyplot
interface other than the subplot(111,projection='whatever') method a
la /examples/api/custom_projection_example.py ? Along these same
lines, is the projection feature documented in greater detail
somewhere? About everything I've figured out has come from
custom_projection_example.py ...
  

There is some additional documentation in the new documentation here:

http://matplotlib.sourceforge.net/doc/html/devel/add_new_projection.html

2. I have a skymap I would like to plot using a particular projection
- what I've been doing so far is specifying x and y coordinates using
mgrid and calling contourf(x,y,data,100) to approximate this. But
what I'd rather do is something like
imshow(data,extent=[-pi,pi,-pi/2,pi/2]) ... when I call that with a
projection axis activated, the projection isn't honored - the image
just appears as a regular square box. Is there any way to get imshow
to respect the projection?
  

As Jae-Joon suggested, try pcolor. It will be slower (and there are no interpolation options), but it should use the custom projection. imshow is really optimized for uniform, rectilinear images.

Cheers,
Mike

···

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

I tried pcolor, but it seems to have much higher memory usage ... the
data set I'm using renders the map using contourf(x,y,z,100)
relatively quickly (~10 sec) and with reasonable memory usage, and
will imshow(z) even faster (although, as I said, without projection) ,
but pcolor(x,y,z) fails with a MemoryError after running for ~5
minutes.

···

On Fri, Sep 5, 2008 at 6:00 AM, Michael Droettboom <mdroe@...86...> wrote:

Erik Tollerud wrote:

I've been playing with some of the projections in matplotlib,
recently, and have some questions/noticed some odd behavior:

1. Is there any way to activate a projection mode with the pyplot
interface other than the subplot(111,projection='whatever') method a
la /examples/api/custom_projection_example.py ? Along these same
lines, is the projection feature documented in greater detail
somewhere? About everything I've figured out has come from
custom_projection_example.py ...

There is some additional documentation in the new documentation here:

http://matplotlib.sourceforge.net/doc/html/devel/add_new_projection.html

2. I have a skymap I would like to plot using a particular projection
- what I've been doing so far is specifying x and y coordinates using
mgrid and calling contourf(x,y,data,100) to approximate this. But
what I'd rather do is something like
imshow(data,extent=[-pi,pi,-pi/2,pi/2]) ... when I call that with a
projection axis activated, the projection isn't honored - the image
just appears as a regular square box. Is there any way to get imshow
to respect the projection?

As Jae-Joon suggested, try pcolor. It will be slower (and there are no
interpolation options), but it should use the custom projection. imshow is
really optimized for uniform, rectilinear images.

Cheers,
Mike

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

--
Erik Tollerud
Graduate Student
Center For Cosmology
Department of Physics and Astronomy
2142 Frederick Reines Hall
University of California, Irvine
Office Phone: (949)824-2587
Cell: (651)307-9409
etolleru@...2143...