diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 681cfc44671e..a5be90a44783 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -5624,8 +5624,11 @@ def _interp_grid(X): 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()): + grid_active = any(axis._major_tick_kw["gridOn"] + for axis in self._get_axis_list()) + # explicit is-True check because get_axisbelow() can also be 'line' + grid_hidden_by_pcolor = self.get_axisbelow() is True + if grid_active and not grid_hidden_by_pcolor: _api.warn_deprecated( "3.5", message="Auto-removal of grids by pcolor() and " "pcolormesh() is deprecated since %(since)s and will be "