-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Labels
Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!Open a pull request against these issues if there are no active ones!keepItems to be ignored by the “Stale” Github ActionItems to be ignored by the “Stale” Github Actiontopic: pcolor/pcolormesh
Milestone
Description
Bug report
Bug summary
When running plt.pcolormesh(X, Y, C, shading='flat'), if C.shape == (nrows, ncols), then if X and Y are 2-D arrays, their shapes must be either (nrows, ncols) or (nrows+1, ncols+1). If shading='gouraud', however, the latter results in an error. The code snippet below uses 1-D arrays for X and Y, but the same error occurs when they are the equivalent 2-D arrays.
Code for reproduction
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-4, 5)
y = np.arange(-6, 7)
xe = np.linspace(-4.5, 4.5, 10)
ye = np.linspace(-6.5, 6.5, 14)
c = np.exp(-0.5*0.125*(x.reshape(1, -1)**2 + y.reshape(-1, 1)**2))
plt.pcolormesh(xe, ye, c, shading='flat') # works
plt.pcolormesh(x, y, c, shading='gouraud') # works
plt.pcolormesh(xe, ye, c, shading='gouraud') # doesn't workActual outcome
Traceback (most recent call last):
File "<ipython-input-67-154f761638cd>", line 1, in <module>
plt.pcolormesh(xe, ye, c, shading='gouraud')
File "/home/egranstedt/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 3245, in pcolormesh
ret = ax.pcolormesh(*args, **kwargs)
File "/home/egranstedt/anaconda3/lib/python3.6/site-packages/matplotlib/__init__.py", line 1892, in inner
return func(ax, *args, **kwargs)
File "/home/egranstedt/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 5569, in pcolormesh
X, Y, C = self._pcolorargs('pcolormesh', *args, allmatch=allmatch)
File "/home/egranstedt/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 5187, in _pcolorargs
C.shape, Nx, Ny, funcname))
TypeError: Dimensions of C (13, 9) are incompatible with X (10) and/or Y (14); see help(pcolormesh)
Expected outcome
I expected pcolormesh would accept the same arrays for X and Y irrespective of the setting of the shading` keyword argument.
Matplotlib version
- The error occurs with Matplotlib version 2.0.0 in the python 3.6 interpreter on Linux (installed via anaconda), but also seems to exist in older versions of Matplotlib (e.g., 1.5.1)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!Open a pull request against these issues if there are no active ones!keepItems to be ignored by the “Stale” Github ActionItems to be ignored by the “Stale” Github Actiontopic: pcolor/pcolormesh