Skip to content

Commit d37551a

Browse files
authored
Merge pull request #15604 from anntzer/deprecate-pcolor-removing-grid
Deprecate auto-removal of grid by pcolor/pcolormesh.
2 parents 22b5721 + 30b6df9 commit d37551a

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
@@ -5670,6 +5670,15 @@ def _interp_grid(X):
56705670
C = cbook.safe_masked_invalid(C)
56715671
return X, Y, C, shading
56725672

5673+
def _pcolor_grid_deprecation_helper(self):
5674+
if any(axis._major_tick_kw["gridOn"]
5675+
for axis in self._get_axis_list()):
5676+
_api.warn_deprecated(
5677+
"3.5", message="Auto-removal of grids by pcolor() and "
5678+
"pcolormesh() is deprecated since %(since)s and will be "
5679+
"removed %(removal)s; please call grid(False) first.")
5680+
self.grid(False)
5681+
56735682
@_preprocess_data()
56745683
@docstring.dedent_interpd
56755684
def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
@@ -5885,7 +5894,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
58855894
collection.set_cmap(cmap)
58865895
collection.set_norm(norm)
58875896
collection._scale_norm(norm, vmin, vmax)
5888-
self.grid(False)
5897+
self._pcolor_grid_deprecation_helper()
58895898

58905899
x = X.compressed()
58915900
y = Y.compressed()
@@ -6122,8 +6131,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
61226131
collection.set_cmap(cmap)
61236132
collection.set_norm(norm)
61246133
collection._scale_norm(norm, vmin, vmax)
6125-
6126-
self.grid(False)
6134+
self._pcolor_grid_deprecation_helper()
61276135

61286136
# Transform from native to data coordinates?
61296137
t = collection._transform

0 commit comments

Comments
 (0)