-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
matplotlib pcolormesh seems to slide some data around on the plot #6331
Comments
Pcolormesh requires X and Y to define a quadrilateral grid. Each Zij determines the color of a quadrilateral defined by X and Y at ij, i,j+1, i+1,j, i+1,j+1. In other words, X and Y define boundaries, not centers. I don't understand how you are generating your X and Y, but I suspect the result is not consistent with what pcolormesh requires. |
Does this mean that Z always needs to be the same size as the layer beneath it? For instance, when plotting basemap maps? |
No, each pcolormesh "object" is independent of each other. On Mon, Apr 25, 2016 at 3:44 AM, John Aiken notifications@github.com
|
also, which version of matplotlib are you using. Older versions had some very weird corner cases that might explain this problem (it was an oddity with handling polygons, but it was only exhibited in contourf3d() plots, IIRC). |
and I just noticed that you already stated that (v1.5.1), so that isn't the problem... |
I thought that there was a problem with parsing nans, so I added some using an example from the basemap documentation for pcolormesh:
However, as you can see this doesn't impact the figure the way it did before. So I tried to replicate this as closely as possible in the code I actually want to get to work and I still get artifacts:
I'm really not clear as to why this is happening. |
Two additional images for reference comparing imshow and pcolormesh. And if we zoom in on the artifact:
|
In your last example, with 1-D As for the dimensions of the original 1-D lons and lats that go into the meshgrid: ideally, lons should be 1 element longer than the second dimension of Z, and lats should be 1 longer than the first dimension of Z, so that there is a boundary quadrilateral for each element of Z. If this is not the case, you lose the last row and column of Z. |
I'm glad you confirmed this because I was inspecting the data I was feeding the plots and it is missing some steps. Nice to know that the problem is typically sitting in front of the computer. |
It looks like no further action is needed so I am closing this. |
@mnky9800n You might add a note to your stackoverflow post to completely resolve it. |
Note, this question was originally posted by me on stackoverflow
Matplotlib Version = 1.5.1
Installation method = anaconda
I'm plotting data using the
matplotlib
functionspcolormesh
andimshow
and when I usepcolormesh
it produces artifacts where it seems to slide some of the data around:whereas
imshow
does not:I was able to produce an example that has the same artifacting
which produces the following figures like so:
Where do these artifacts come from? There isn't anything wrong with the data as far as I can tell since the original data and the made up data produce the same result.
The text was updated successfully, but these errors were encountered: