mbauer wrote:
> Matplotlib users,
>
> I've been using pcolor and pcolormesh to plot results from the NCEP  
> Reanalysis. I've noticed that the plotted values are slightly offset.  
> Googling around I see that matlab has this quality, which I assume  
> matplotlib inherited.
>
>      # If your georeferenced image is in lat/long coordinates (i.e.  
> each data row is along a line of
>        constant latitude, each column a line of equal longitude), ...  
> you MUST remember to offset your
>        coordinates by one-half of the pixel spacing. This is because  
> of the different behaviors of
>        p_color and image when given the same data.
>       1. image will center the drawn (i,j) pixel on the (i,j)th entry of  
> the X/Y matrices.
>       2. p_color with shading flat will draw a panel between the (i,j), 
> (i+1,j),(i+1,j+1),(i,j+1)
>          coordinates of the X/Y matrices with a color corresponding to  
> the data value at (i,j). Thus
>          everything will appear shifted by one half a pixel spacing.
>
> and
>       % Since the grid is rectangluar in lat/long (i.e. not
>       % really a projection at all, althouhg it is included in
>       % m_map under the name 'equidistant cyldindrical'), we
>       % don't want to use the 'image' technique. Instead...
>       % Create a grid, offsetting by half a grid point to account
>       % for the flat pcolor
>       [Plg,Plt]=meshgrid(Plon-0.25,Plat+0.25);
>
> The data I'm using uses polar grids centered on +-90.0 which give a  
> latitude array as such
> [-90.  -87.5 -85.  -82.5 -80.  -77.5 -75.  -72.5 -70.  -67.5 -65.  -62.5
>   -60.  -57.5 -55.  -52.5 -50.  -47.5 -45.  -42.5 -40.  -37.5 -35.   
> -32.5
>   -30.  -27.5 -25.  -22.5 -20.  -17.5 -15.  -12.5 -10.   -7.5  -5.    
> -2.5
>     0.    2.5   5.    7.5  10.   12.5  15.   17.5  20.   22.5  25.    
> 27.5
>    30.   32.5  35.   37.5  40.   42.5  45.   47.5  50.   52.5  55.    
> 57.5
>    60.   62.5  65.   67.5  70.   72.5  75.   77.5  80.   82.5  85.    
> 87.5
>    90. ]
>
> Is there a simple way to "shift" this data so my global plots look  
> correct? So far my results result in an "empty" line along the south  
> pole or I end up with an extra latitude which pcolor doesn't like.
>
> Thanks,
>
> Mike
>
>   

Mike:  From the pcolor docstring:

X and Y, if given, specify the (x,y) coordinates of the colored
    quadrilaterals; the quadrilateral for C[i,j] has corners at
    (X[i,j],Y[i,j]), (X[i,j+1],Y[i,j+1]), (X[i+1,j],Y[i+1,j]),
    (X[i+1,j+1],Y[i+1,j+1]).  Ideally the dimensions of X and Y
    should be one greater than those of C; if the dimensions are the
    same, then the last row and column of C will be ignored.

So it may be easier to modify your data (by averaging adjacent values to 
they reflect the mid-point of each grid box) than to modify the vertices.

-Jeff

-- 
Jeffrey S. Whitaker         Phone  : (303)497-6313
Meteorologist               FAX    : (303)497-6449
NOAA/OAR/PSD  R/PSD1        Email  : [EMAIL PROTECTED]
325 Broadway                Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to