Skip to content

Commit 968b96e

Browse files
committed
Deprecate auto-removal of grid by pcolor/pcolormesh.
1 parent 5914990 commit 968b96e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,9 @@ The ``TTFPATH`` and ``AFMPATH`` environment variables
169169
Support for the (undocumented) ``TTFPATH`` and ``AFMPATH`` environment
170170
variables is deprecated. Additional fonts may be registered using
171171
``matplotlib.font_manager.fontManager.addfont()``.
172+
173+
Auto-removal of grids by `~.Axes.pcolor` and `~.Axes.pcolormesh`
174+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
175+
`~.Axes.pcolor` and `~.Axes.pcolormesh` currently remove any visible axes major
176+
grid. This behavior is deprecated; please explicitly call ``ax.grid(False)``
177+
to remove the grid.

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5652,6 +5652,14 @@ def _pcolorargs(funcname, *args, allmatch=False):
56525652
C = cbook.safe_masked_invalid(C)
56535653
return X, Y, C
56545654

5655+
def _pcolor_grid_deprecation_helper(self):
5656+
if any(axis._gridOnMajor for axis in self._get_axis_list()):
5657+
cbook.warn_deprecated(
5658+
"3.3", message="Auto-removal of grids by pcolor() and "
5659+
"pcolormesh() is deprecated since %(since)s and will be "
5660+
"removed %(removal)s; please call grid(False) first.")
5661+
self.grid(False)
5662+
56555663
@_preprocess_data()
56565664
@docstring.dedent_interpd
56575665
def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
@@ -5852,7 +5860,7 @@ def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
58525860
collection.set_cmap(cmap)
58535861
collection.set_norm(norm)
58545862
collection._scale_norm(norm, vmin, vmax)
5855-
self.grid(False)
5863+
self._pcolor_grid_deprecation_helper()
58565864

58575865
x = X.compressed()
58585866
y = Y.compressed()
@@ -6066,8 +6074,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
60666074
collection.set_cmap(cmap)
60676075
collection.set_norm(norm)
60686076
collection._scale_norm(norm, vmin, vmax)
6069-
6070-
self.grid(False)
6077+
self._pcolor_grid_deprecation_helper()
60716078

60726079
# Transform from native to data coordinates?
60736080
t = collection._transform

0 commit comments

Comments
 (0)