diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 2f6fc2cff9a0..83384fd37646 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -791,8 +791,13 @@ def clear(self): # Clear the callback registry for this axis, or it may "leak" self.callbacks = cbook.CallbackRegistry() - self._reset_major_tick_kw() - self._reset_minor_tick_kw() + # whether the grids are on + self._major_tick_kw['gridOn'] = ( + mpl.rcParams['axes.grid'] and + mpl.rcParams['axes.grid.which'] in ('both', 'major')) + self._minor_tick_kw['gridOn'] = ( + mpl.rcParams['axes.grid'] and + mpl.rcParams['axes.grid.which'] in ('both', 'minor')) self.reset_ticks() self.converter = None diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index f949a5ce4ab3..7950e5b8306e 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -6955,6 +6955,21 @@ def test_2dcolor_plot(fig_test, fig_ref): axs[4].bar(np.arange(10), np.arange(10), color=color.reshape((1, -1))) +@check_figures_equal(extensions=['png']) +def test_shared_axes_clear(fig_test, fig_ref): + x = np.arange(0.0, 2*np.pi, 0.01) + y = np.sin(x) + + axs = fig_ref.subplots(2, 2, sharex=True, sharey=True) + for ax in axs.flat: + ax.plot(x, y) + + axs = fig_test.subplots(2, 2, sharex=True, sharey=True) + for ax in axs.flat: + ax.clear() + ax.plot(x, y) + + def test_shared_axes_retick(): fig, axs = plt.subplots(2, 2, sharex='all', sharey='all') pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy