Skip to content

Commit 8cd2c91

Browse files
authored
Merge pull request matplotlib#27778 from meeseeksmachine/auto-backport-of-pr-27773-on-v3.8.x
2 parents 87a52b5 + df6c029 commit 8cd2c91

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5852,7 +5852,7 @@ def _pcolorargs(self, funcname, *args, shading='auto', **kwargs):
58525852
def _interp_grid(X):
58535853
# helper for below
58545854
if np.shape(X)[1] > 1:
5855-
dX = np.diff(X, axis=1)/2.
5855+
dX = np.diff(X, axis=1) * 0.5
58565856
if not (np.all(dX >= 0) or np.all(dX <= 0)):
58575857
_api.warn_external(
58585858
f"The input coordinates to {funcname} are "

lib/matplotlib/tests/test_axes.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,19 @@ def test_pcolorargs():
14991499
ax.pcolormesh(X, Y, Z, shading='auto')
15001500

15011501

1502+
def test_pcolormesh_underflow_error():
1503+
"""
1504+
Test that underflow errors don't crop up in pcolormesh. Probably
1505+
a numpy bug (https://github.com/numpy/numpy/issues/25810).
1506+
"""
1507+
with np.errstate(under="raise"):
1508+
x = np.arange(0, 3, 0.1)
1509+
y = np.arange(0, 6, 0.1)
1510+
z = np.random.randn(len(y), len(x))
1511+
fig, ax = plt.subplots()
1512+
ax.pcolormesh(x, y, z)
1513+
1514+
15021515
def test_pcolorargs_with_read_only():
15031516
x = np.arange(6).reshape(2, 3)
15041517
xmask = np.broadcast_to([False, True, False], x.shape) # read-only array

0 commit comments

Comments
 (0)