basemap icon indicating copy to clipboard operation
basemap copied to clipboard

pcolormesh actually requires the X,Y to be +1 size of the data array

Open akrherz opened this issue 11 years ago • 7 comments

Kind of ran into an unexpected quirk with pcolormesh that perhaps could be improved to save users like me from themselves!

The X, Y arrays to this function need to be 1 larger than the data array so that the bounds of the grid cell are known. Matplotlib's code silently trims the array and will drop the rightmost column and top row.

The examples/plotsst.py suffers from this issue as X,Y,data are all (720, 1440), so the plot is not complete.

I am not sure what to suggest for a fix to this, perhaps simply documenting it is sufficient or maybe basemap should complain when this happens? If you think I should take my whining upstream to matplotlib, that's understandable :)

thank you.

akrherz avatar May 30 '13 14:05 akrherz

Hi Daryl,

It works like this, pcolormesh fills space between the point defined by X,Y, so this way you get the number of intervals less than the number of points... I read it somewhere in matplotlib docs.

Cheers

Oleksandr (Sasha) Huziy

2013/5/30 daryl herzmann [email protected]

Kind of ran into an unexpected quirk with pcolormesh that perhaps could be improved to save users like me from themselves!

The X, Y arrays to this function need to be 1 larger than the data array so that the bounds of the grid cell are known. Matplotlib's code silently trims the array and will drop the rightmost column and top row.

The examples/plotsst.py suffers from this issue as X,Y,data are all (720, 1440), so the plot is not complete.

I am not sure what to suggest for a fix to this, perhaps simply documenting it is sufficient or maybe basemap should complain when this happens? If you think I should take my whining upstream to matplotlib, that's understandable :)

thank you.

— Reply to this email directly or view it on GitHubhttps://github.com/matplotlib/basemap/issues/107 .

guziy avatar May 30 '13 14:05 guziy

Thanks guziy, I agree that it is necessary for X,Y to be one larger than the data. I would just like to see it documented in the function and the basemap examples fixed to properly account for this.

akrherz avatar May 30 '13 14:05 akrherz

Anyone want to submit a pull request for this?

jswhit avatar Nov 05 '13 18:11 jswhit

Hi Jeff:

I've sent the pull request, though I do not know how to connect it with the issue... Please, see if it is really of interest.

https://github.com/matplotlib/basemap/pull/132

Cheers

2013/11/5 Jeff Whitaker [email protected]

Anyone want to submit a pull request for this?

— Reply to this email directly or view it on GitHubhttps://github.com/matplotlib/basemap/issues/107#issuecomment-27799326 .

Sasha

guziy avatar Nov 05 '13 22:11 guziy

Ok, I see you want the examples also to be fixed, that'll probably take a bit more effort))

2013/11/5 Oleksandr Huziy [email protected]

Hi Jeff:

I've sent the pull request, though I do not know how to connect it with the issue... Please, see if it is really of interest.

https://github.com/matplotlib/basemap/pull/132

Cheers

2013/11/5 Jeff Whitaker [email protected]

Anyone want to submit a pull request for this?

— Reply to this email directly or view it on GitHubhttps://github.com/matplotlib/basemap/issues/107#issuecomment-27799326 .

Sasha

Sasha

guziy avatar Nov 06 '13 02:11 guziy

Recently my friend asked me for a pcolormesh example and referred to this issue, and reminded me that I completely forgot to work on an example. So I've created one for him and thought maybe it could be useful for someone else: http://nbviewer.ipython.org/github/guziy/PyNotebooks/blob/master/pcolormesh_example.ipynb

Cheers

guziy avatar Jul 25 '14 21:07 guziy

It would be good if get_array() (or some other, similar method, get_data()?) returned the original data. Otherwise, modifying the data in get_array() and re-plotting would keep truncating the data upon each iteration.

demisjohn avatar Jan 17 '16 15:01 demisjohn