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

Commitc946d3c

Browse files
authored
Merge pull request#20830 from meeseeksmachine/auto-backport-of-pr-20826-on-v3.4.x
Backport PR#20826 on branch v3.4.x (Fix clear of Axes that are shared.)
2 parentsda6b1fe +4b5ea5a commitc946d3c

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
@@ -791,8 +791,13 @@ def clear(self):
791791
# Clear the callback registry for this axis, or it may "leak"
792792
self.callbacks=cbook.CallbackRegistry()
793793

794-
self._reset_major_tick_kw()
795-
self._reset_minor_tick_kw()
794+
# whether the grids are on
795+
self._major_tick_kw['gridOn']= (
796+
mpl.rcParams['axes.grid']and
797+
mpl.rcParams['axes.grid.which']in ('both','major'))
798+
self._minor_tick_kw['gridOn']= (
799+
mpl.rcParams['axes.grid']and
800+
mpl.rcParams['axes.grid.which']in ('both','minor'))
796801
self.reset_ticks()
797802

798803
self.converter=None

‎lib/matplotlib/tests/test_axes.py

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

69576957

6958+
@check_figures_equal(extensions=['png'])
6959+
deftest_shared_axes_clear(fig_test,fig_ref):
6960+
x=np.arange(0.0,2*np.pi,0.01)
6961+
y=np.sin(x)
6962+
6963+
axs=fig_ref.subplots(2,2,sharex=True,sharey=True)
6964+
foraxinaxs.flat:
6965+
ax.plot(x,y)
6966+
6967+
axs=fig_test.subplots(2,2,sharex=True,sharey=True)
6968+
foraxinaxs.flat:
6969+
ax.clear()
6970+
ax.plot(x,y)
6971+
6972+
69586973
deftest_shared_axes_retick():
69596974
fig,axs=plt.subplots(2,2,sharex='all',sharey='all')
69606975

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp