Skip to content

Commit cb9ddbc

Browse files
authored
Merge pull request #9213 from matplotlib/auto-backport-of-pr-9168
Backport PR #9168 on branch v2.1.x
2 parents f5893ce + 788abaf commit cb9ddbc

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5620,15 +5620,16 @@ def pcolormesh(self, *args, **kwargs):
56205620

56215621
X, Y, C = self._pcolorargs('pcolormesh', *args, allmatch=allmatch)
56225622
Ny, Nx = X.shape
5623-
5623+
X = X.ravel()
5624+
Y = Y.ravel()
56245625
# unit conversion allows e.g. datetime objects as axis values
56255626
self._process_unit_info(xdata=X, ydata=Y, kwargs=kwargs)
56265627
X = self.convert_xunits(X)
56275628
Y = self.convert_yunits(Y)
56285629

56295630
# convert to one dimensional arrays
56305631
C = C.ravel()
5631-
coords = np.column_stack((X.flat, Y.flat)).astype(float, copy=False)
5632+
coords = np.column_stack((X, Y)).astype(float, copy=False)
56325633

56335634
collection = mcoll.QuadMesh(Nx - 1, Ny - 1, coords,
56345635
antialiased=antialiased, shading=shading,

lib/matplotlib/tests/test_axes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4929,6 +4929,17 @@ def test_broken_barh_empty():
49294929
ax.broken_barh([], (.1, .5))
49304930

49314931

4932+
def test_pandas_pcolormesh():
4933+
pd = pytest.importorskip('pandas')
4934+
4935+
time = pd.date_range('2000-01-01', periods=10)
4936+
depth = np.arange(20)
4937+
data = np.random.rand(20, 10)
4938+
4939+
fig, ax = plt.subplots()
4940+
ax.pcolormesh(time, depth, data)
4941+
4942+
49324943
def test_pandas_indexing_dates():
49334944
pd = pytest.importorskip('pandas')
49344945

0 commit comments

Comments
 (0)