Open egranstedt opened 7 years ago
Exact work:
Dimensions of c
are wrong. Try this:
import numpy as np
import matplotlib.pyplot as plt
xe = np.linspace(-4.5, 4.5, 10)
ye = np.linspace(-6.5, 6.5, 14)
c = np.exp(-0.5*0.125*(xe.reshape(1, -1)**2 + ye.reshape(-1, 1)**2))
plt.pcolormesh(xe, ye, c, shading='gouraud')
plt.show()
The actual problem here is that if you don't use the Gouraud shading, pcolormesh is capable of automatically adjusting dimensions so that the original example works. The question is what it will take for Gouraud shading to work when given the slightly mis-shaped data.
Just checking if there has been an on this? I followed pull request 9594 but it isn't clear it got done.
There are two distinct modes of operation here. When flat shading, pcolormesh is like a histogram where you define edges and then center fill color. When then gouraud, it is defined at the vertices. This should be consistent!
@jklymak since you just finished working on the 'flat' case, I wonder if you have any thoughts here (and on the linked PR)?
I think interpolating the grid midpoints is "fine" to make gouraud work, maybe with a warning. The linked PR died because the author insisted on a kwarg controlling whether that would happen or not, which I didn't agree with.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
This is still an issue.
Bug report
Bug summary
When running
plt.pcolormesh(X, Y, C, shading='flat')
, ifC.shape == (nrows, ncols)
, then ifX
andY
are 2-D arrays, their shapes must be either(nrows, ncols)
or(nrows+1, ncols+1)
. Ifshading='gouraud'
, however, the latter results in an error. The code snippet below uses 1-D arrays forX
andY
, but the same error occurs when they are the equivalent 2-D arrays.Code for reproduction
Actual outcome
Expected outcome
I expected
pcolormesh
would accept the same arrays forX
andY irrespective of the setting of the
shading` keyword argument.Matplotlib version