Skip to content

Commit ce1daf7

Browse files
committed
Deprecate auto-removal of grid by pcolor/pcolormesh.
1 parent 2c5c351 commit ce1daf7

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

doc/api/next_api_changes/deprecations.rst

+6
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,9 @@ e.g. `.FuncFormatter`.
159159
``OldAutoLocator``
160160
~~~~~~~~~~~~~~~~~~
161161
This ticker is deprecated.
162+
163+
Auto-removal of grids by `~.Axes.pcolor` and `~.Axes.pcolormesh`
164+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
165+
`~.Axes.pcolor` and `~.Axes.pcolormesh` currently remove any visible axes major
166+
grid. This behavior is deprecated; please explicitly call ``ax.grid(False)``
167+
to remove the grid.

lib/matplotlib/axes/_axes.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -5654,6 +5654,14 @@ def _pcolorargs(funcname, *args, allmatch=False):
56545654
C = cbook.safe_masked_invalid(C)
56555655
return X, Y, C
56565656

5657+
def _pcolor_grid_deprecation_helper(self):
5658+
if any(axis._gridOnMajor for axis in self._get_axis_list()):
5659+
cbook.warn_deprecated(
5660+
"3.3", message="Auto-removal of grids by pcolor() and "
5661+
"pcolormesh() is deprecated since %(since)s and will be "
5662+
"removed %(removal)s; please call grid(False) first.")
5663+
self.grid(False)
5664+
56575665
@_preprocess_data()
56585666
@docstring.dedent_interpd
56595667
def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
@@ -5854,7 +5862,7 @@ def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
58545862
collection.set_cmap(cmap)
58555863
collection.set_norm(norm)
58565864
collection._scale_norm(norm, vmin, vmax)
5857-
self.grid(False)
5865+
self._pcolor_grid_deprecation_helper()
58585866

58595867
x = X.compressed()
58605868
y = Y.compressed()
@@ -6068,8 +6076,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
60686076
collection.set_cmap(cmap)
60696077
collection.set_norm(norm)
60706078
collection._scale_norm(norm, vmin, vmax)
6071-
6072-
self.grid(False)
6079+
self._pcolor_grid_deprecation_helper()
60736080

60746081
# Transform from native to data coordinates?
60756082
t = collection._transform

0 commit comments

Comments
 (0)