Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitabf5f04

Browse files
authored
Merge pull request#20826 from QuLogic/fix-shared-clear
Fix clear of Axes that are shared.
2 parents495a985 +c222998 commitabf5f04

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

‎lib/matplotlib/axis.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,13 @@ def clear(self):
806806
# Clear the callback registry for this axis, or it may "leak"
807807
self.callbacks=cbook.CallbackRegistry()
808808

809-
self._reset_major_tick_kw()
810-
self._reset_minor_tick_kw()
809+
# whether the grids are on
810+
self._major_tick_kw['gridOn']= (
811+
mpl.rcParams['axes.grid']and
812+
mpl.rcParams['axes.grid.which']in ('both','major'))
813+
self._minor_tick_kw['gridOn']= (
814+
mpl.rcParams['axes.grid']and
815+
mpl.rcParams['axes.grid.which']in ('both','minor'))
811816
self.reset_ticks()
812817

813818
self.converter=None

‎lib/matplotlib/tests/test_axes.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6961,6 +6961,21 @@ def test_2dcolor_plot(fig_test, fig_ref):
69616961
axs[4].bar(np.arange(10),np.arange(10),color=color.reshape((1,-1)))
69626962

69636963

6964+
@check_figures_equal(extensions=['png'])
6965+
deftest_shared_axes_clear(fig_test,fig_ref):
6966+
x=np.arange(0.0,2*np.pi,0.01)
6967+
y=np.sin(x)
6968+
6969+
axs=fig_ref.subplots(2,2,sharex=True,sharey=True)
6970+
foraxinaxs.flat:
6971+
ax.plot(x,y)
6972+
6973+
axs=fig_test.subplots(2,2,sharex=True,sharey=True)
6974+
foraxinaxs.flat:
6975+
ax.clear()
6976+
ax.plot(x,y)
6977+
6978+
69646979
deftest_shared_axes_retick():
69656980
fig,axs=plt.subplots(2,2,sharex='all',sharey='all')
69666981

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp