67 lines
2.4 KiB
Diff
67 lines
2.4 KiB
Diff
From 4dabe86f04281c9ec307ecb2586f29f9c03b1257 Mon Sep 17 00:00:00 2001
|
|
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
|
Date: Tue, 5 Oct 2021 22:14:49 -0400
|
|
Subject: [PATCH 5/5] Fix snap argument to pcolormesh
|
|
|
|
If it's passed as a keyword argument, then it needs to be removed from
|
|
`kwargs`, or not passed again explicitly. Other handling of `snap` uses
|
|
`setdefault`, so do that here too.
|
|
|
|
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
|
---
|
|
lib/matplotlib/axes/_axes.py | 5 +++--
|
|
lib/matplotlib/tests/test_axes.py | 7 ++++---
|
|
2 files changed, 7 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py
|
|
index 4eca2e6b0b..dcaadb8be3 100644
|
|
--- a/lib/matplotlib/axes/_axes.py
|
|
+++ b/lib/matplotlib/axes/_axes.py
|
|
@@ -6016,9 +6016,10 @@ default: :rc:`scatter.edgecolors`
|
|
# convert to one dimensional array
|
|
C = C.ravel()
|
|
|
|
- snap = kwargs.get('snap', rcParams['pcolormesh.snap'])
|
|
+ kwargs.setdefault('snap', rcParams['pcolormesh.snap'])
|
|
+
|
|
collection = mcoll.QuadMesh(
|
|
- coords, antialiased=antialiased, shading=shading, snap=snap,
|
|
+ coords, antialiased=antialiased, shading=shading,
|
|
array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs)
|
|
collection._scale_norm(norm, vmin, vmax)
|
|
self._pcolor_grid_deprecation_helper()
|
|
diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py
|
|
index a5e678d048..935cd11c1e 100644
|
|
--- a/lib/matplotlib/tests/test_axes.py
|
|
+++ b/lib/matplotlib/tests/test_axes.py
|
|
@@ -1250,22 +1250,23 @@ def test_pcolorflaterror():
|
|
ax.pcolormesh(x, y, Z, shading='flat')
|
|
|
|
|
|
+@pytest.mark.parametrize('snap', [False, True])
|
|
@check_figures_equal(extensions=["png"])
|
|
-def test_pcolorauto(fig_test, fig_ref):
|
|
+def test_pcolorauto(fig_test, fig_ref, snap):
|
|
ax = fig_test.subplots()
|
|
x = np.arange(0, 10)
|
|
y = np.arange(0, 4)
|
|
np.random.seed(19680801)
|
|
Z = np.random.randn(3, 9)
|
|
# this is the same as flat; note that auto is default
|
|
- ax.pcolormesh(x, y, Z)
|
|
+ ax.pcolormesh(x, y, Z, snap=snap)
|
|
|
|
ax = fig_ref.subplots()
|
|
# specify the centers
|
|
x2 = x[:-1] + np.diff(x) / 2
|
|
y2 = y[:-1] + np.diff(y) / 2
|
|
# this is same as nearest:
|
|
- ax.pcolormesh(x2, y2, Z)
|
|
+ ax.pcolormesh(x2, y2, Z, snap=snap)
|
|
|
|
|
|
@image_comparison(['canonical'])
|
|
--
|
|
2.31.1
|
|
|