From 30b6df947d8ac5b42c407719ca4c9defb31fba85 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 5 Nov 2019 22:09:43 +0100 Subject: [PATCH] Deprecate auto-removal of grid by pcolor/pcolormesh. --- doc/api/next_api_changes/deprecations/15604-AL.rst | 5 +++++ lib/matplotlib/axes/_axes.py | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 doc/api/next_api_changes/deprecations/15604-AL.rst diff --git a/doc/api/next_api_changes/deprecations/15604-AL.rst b/doc/api/next_api_changes/deprecations/15604-AL.rst new file mode 100644 index 000000000000..d87b4205fc93 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/15604-AL.rst @@ -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. diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 3d9d649499e4..d1d9e6e87e33 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -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, @@ -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() @@ -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