Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/deprecations/15604-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Auto-removal of grids by `~.Axes.pcolor` and `~.Axes.pcolormesh`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`~.Axes.pcolor` and `~.Axes.pcolormesh` currently remove any visible axes major
grid. This behavior is deprecated; please explicitly call ``ax.grid(False)``
to remove the grid.
14 changes: 11 additions & 3 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5721,6 +5721,15 @@ def _interp_grid(X):
C = cbook.safe_masked_invalid(C)
return X, Y, C, shading

def _pcolor_grid_deprecation_helper(self):
if any(axis._major_tick_kw["gridOn"]
for axis in self._get_axis_list()):
_api.warn_deprecated(
"3.5", message="Auto-removal of grids by pcolor() and "
"pcolormesh() is deprecated since %(since)s and will be "
"removed %(removal)s; please call grid(False) first.")
self.grid(False)

@_preprocess_data()
@docstring.dedent_interpd
def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
Expand Down Expand Up @@ -5936,7 +5945,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
collection.set_cmap(cmap)
collection.set_norm(norm)
collection._scale_norm(norm, vmin, vmax)
self.grid(False)
self._pcolor_grid_deprecation_helper()

x = X.compressed()
y = Y.compressed()
Expand Down Expand Up @@ -6173,8 +6182,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
collection.set_cmap(cmap)
collection.set_norm(norm)
collection._scale_norm(norm, vmin, vmax)

self.grid(False)
self._pcolor_grid_deprecation_helper()

# Transform from native to data coordinates?
t = collection._transform
Expand Down