Skip to content

Commit 30b6df9

Browse files
committed
Deprecate auto-removal of grid by pcolor/pcolormesh.
1 parent bc5d5b8 commit 30b6df9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Auto-removal of grids by `~.Axes.pcolor` and `~.Axes.pcolormesh`
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
`~.Axes.pcolor` and `~.Axes.pcolormesh` currently remove any visible axes major
4+
grid. This behavior is deprecated; please explicitly call ``ax.grid(False)``
5+
to remove the grid.

lib/matplotlib/axes/_axes.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5721,6 +5721,15 @@ def _interp_grid(X):
57215721
C = cbook.safe_masked_invalid(C)
57225722
return X, Y, C, shading
57235723

5724+
def _pcolor_grid_deprecation_helper(self):
5725+
if any(axis._major_tick_kw["gridOn"]
5726+
for axis in self._get_axis_list()):
5727+
_api.warn_deprecated(
5728+
"3.5", message="Auto-removal of grids by pcolor() and "
5729+
"pcolormesh() is deprecated since %(since)s and will be "
5730+
"removed %(removal)s; please call grid(False) first.")
5731+
self.grid(False)
5732+
57245733
@_preprocess_data()
57255734
@docstring.dedent_interpd
57265735
def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
@@ -5936,7 +5945,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
59365945
collection.set_cmap(cmap)
59375946
collection.set_norm(norm)
59385947
collection._scale_norm(norm, vmin, vmax)
5939-
self.grid(False)
5948+
self._pcolor_grid_deprecation_helper()
59405949

59415950
x = X.compressed()
59425951
y = Y.compressed()
@@ -6173,8 +6182,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
61736182
collection.set_cmap(cmap)
61746183
collection.set_norm(norm)
61756184
collection._scale_norm(norm, vmin, vmax)
6176-
6177-
self.grid(False)
6185+
self._pcolor_grid_deprecation_helper()
61786186

61796187
# Transform from native to data coordinates?
61806188
t = collection._transform

0 commit comments

Comments
 (0)