imshow size limitations?

Nope, still only getting the last corner. Let me give a little more of my code:

import numpy as N
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

w, h, DPI = (8.2, 6.2, 50)
fig = Figure(figsize=(w, h),
             dpi=DPI,
             frameon=False)
ax = fig.add_subplot(1,1,1)
canvas = FigureCanvas(fig)

nx, xmin, xmax = (int(w*DPI), -0.5, 0.5)
ny, ymin, ymax = (int(h*DPI), 0.6, 1.2)
W = N.zeros((ny,nx),N.complex)

## Generate non-trivial W; unnecessary for code to run, I think

argW = N.angle(W)

ax.set_xlim(0, nx)
ax.set_ylim(ny, 0)
ax.imshow(argW[0:ny/2, 0:nx/2], extent=(0, nx/2 - 1, ny/2 - 1, 0))
ax.hold(True)
ax.imshow(argW[ny/2:-1, 0:nx/2], extent=(0, nx/2 - 1, ny, ny/2))
ax.imshow(argW[0:ny/2, nx/2:-1], extent=(nx/2, nx, ny/2 - 1, 0))
ax.imshow(argW[ny/2:-1, nx/2:-1], extent=(nx/2, nx, ny, ny/2))
canvas.print_figure(fid, dpi=DPI)

DG

···

--- On Sun, 2/28/10, David Goldsmith <d_l_goldsmith@...9...> wrote:

> >> > Question 2) is there some way I can add
> pieces of the
> >> array incrementally to
> >> > the image into their proper place,
i.e.,
> modify the
> >> following code:
> >> >
> >> > ax.imshow(image[0:ny/2+1,
0:nx/2+1]) #
> upper
> >> left corner of image
> >> > ax.hold(True)
> >> > ax.imshow(argW[ny/2+1:-1,
0:nx/2+1]) #
> lower
> >> left corner of image
> >> > ax.imshow(argW[0:ny/2+1,
nx/2+1:-1]) #
> upper
> >> right corner of image
> >> > ax.imshow(argW[ny/2+1:-1,
nx/2+1:-1])
> # lower
> >> right corner of image
> >>
> >> Try the extents keyword argument. It let's
you
> specify the
> >> corners of
> >> the image in data coordinates.
> >>
> >> Ryan
> >
> > Hi, Ryan, thanks! Can you be a little more
specific
> as to how I should try that? I tried:
> >
> > ax.imshow(argW[0:ny/2+1, 0:nx/2+1], cmap_name,
> extent=(0,nx/2,ny/2,0))
> > ax.hold(True)
> > ax.imshow(argW[ny/2+1:-1, 0:nx/2+1], cmap_name,
> extent=(0,nx/2,ny,ny/2))
> > ax.imshow(argW[0:ny/2+1, nx/2+1:-1], cmap_name,
> extent=(nx/2,nx,ny/2,0))
> > ax.imshow(argW[ny/2+1:-1, nx/2+1:-1], cmap_name,
> extent=(nx/2,nx,ny,ny/2))
> >
> > which didn't work (I only got one "corner" - the
last
> one, I think - i.e., I think it's still just putting
> subsequent images on top of prior ones).
>
> Based on just a quick look, I'd make sure:
>
> 1) To set the x and y limits appropriately:
>
> ax.set_xlim(0, nx)
> ax.set_ylim(ny, 0)

I'll try it out and report back.

David Goldsmith wrote:

Question 2) is there some way I can add
            

pieces of the
      

array incrementally to
          

the image into their proper place,
            

i.e.,
    

modify the
      

following code:
          

    ax.imshow(image[0:ny/2+1,
            

0:nx/2+1]) #
    

upper
      

left corner of image
          

    ax.hold(True)
    ax.imshow(argW[ny/2+1:-1,
            

0:nx/2+1]) #
    

lower
      

left corner of image
          

    ax.imshow(argW[0:ny/2+1,
            

nx/2+1:-1]) #
    

upper
      

right corner of image
          

    ax.imshow(argW[ny/2+1:-1,
            

nx/2+1:-1])
    

# lower
      

right corner of image

Try the extents keyword argument. It let's
          

you
    

specify the
      

corners of
the image in data coordinates.

Ryan
          

Hi, Ryan, thanks! Can you be a little more
        

specific
    

as to how I should try that? I tried:
      

ax.imshow(argW[0:ny/2+1, 0:nx/2+1], cmap_name,
        

extent=(0,nx/2,ny/2,0))
      

ax.hold(True)
ax.imshow(argW[ny/2+1:-1, 0:nx/2+1], cmap_name,
        

extent=(0,nx/2,ny,ny/2))
      

ax.imshow(argW[0:ny/2+1, nx/2+1:-1], cmap_name,
        

extent=(nx/2,nx,ny/2,0))
      

ax.imshow(argW[ny/2+1:-1, nx/2+1:-1], cmap_name,
        

extent=(nx/2,nx,ny,ny/2))
      

which didn't work (I only got one "corner" - the
        

last
    

one, I think - i.e., I think it's still just putting
subsequent images on top of prior ones).

Based on just a quick look, I'd make sure:

1) To set the x and y limits appropriately:

ax.set_xlim(0, nx)
ax.set_ylim(ny, 0)
      

I'll try it out and report back.
    
Nope, still only getting the last corner. Let me give a little more of my code:
  
David: Just add

ax.set_xlim(0,nx)
ax.set_ylim(0,ny)

after you imshow calls. The axes limits are being automatically set to match your last invocation of imshow.

-Jeff

···

--- On Sun, 2/28/10, David Goldsmith <d_l_goldsmith@...9...> wrote:
import numpy as N
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

w, h, DPI = (8.2, 6.2, 50)
fig = Figure(figsize=(w, h), dpi=DPI,
             frameon=False)
ax = fig.add_subplot(1,1,1)
canvas = FigureCanvas(fig)

nx, xmin, xmax = (int(w*DPI), -0.5, 0.5)
ny, ymin, ymax = (int(h*DPI), 0.6, 1.2)
W = N.zeros((ny,nx),N.complex)

## Generate non-trivial W; unnecessary for code to run, I think

argW = N.angle(W)

ax.set_xlim(0, nx)
ax.set_ylim(ny, 0)
ax.imshow(argW[0:ny/2, 0:nx/2], extent=(0, nx/2 - 1, ny/2 - 1, 0))
ax.hold(True)
ax.imshow(argW[ny/2:-1, 0:nx/2], extent=(0, nx/2 - 1, ny, ny/2))
ax.imshow(argW[0:ny/2, nx/2:-1], extent=(nx/2, nx, ny/2 - 1, 0))
ax.imshow(argW[ny/2:-1, nx/2:-1], extent=(nx/2, nx, ny, ny/2))
canvas.print_figure(fid, dpi=DPI)

DG