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

Commitfcf7b81

Browse files
authored
Merge pull request#21605 from meeseeksmachine/auto-backport-of-pr-21317-on-v3.5.x
Backport PR#21317 on branch v3.5.x (Move label hiding rectilinear-only check into _label_outer_{x,y}axis.)
2 parents2543251 +e4325e6 commitfcf7b81

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

‎lib/matplotlib/axes/_subplots.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
importmatplotlibasmpl
12
frommatplotlibimport_api,cbook
23
frommatplotlib.axes._axesimportAxes
34
frommatplotlib.gridspecimportGridSpec,SubplotSpec
@@ -109,10 +110,13 @@ def label_outer(self):
109110
labels are on the top side); y-labels only for subplots on the first
110111
column (or last column, if labels are on the right side).
111112
"""
112-
self._label_outer_xaxis()
113-
self._label_outer_yaxis()
113+
self._label_outer_xaxis(check_patch=False)
114+
self._label_outer_yaxis(check_patch=False)
114115

115-
def_label_outer_xaxis(self):
116+
def_label_outer_xaxis(self,*,check_patch):
117+
# see documentation in label_outer.
118+
ifcheck_patchandnotisinstance(self.patch,mpl.patches.Rectangle):
119+
return
116120
ss=self.get_subplotspec()
117121
label_position=self.xaxis.get_label_position()
118122
ifnotss.is_first_row():# Remove top label/ticklabels/offsettext.
@@ -128,7 +132,10 @@ def _label_outer_xaxis(self):
128132
ifself.xaxis.offsetText.get_position()[1]==0:
129133
self.xaxis.offsetText.set_visible(False)
130134

131-
def_label_outer_yaxis(self):
135+
def_label_outer_yaxis(self,*,check_patch):
136+
# see documentation in label_outer.
137+
ifcheck_patchandnotisinstance(self.patch,mpl.patches.Rectangle):
138+
return
132139
ss=self.get_subplotspec()
133140
label_position=self.yaxis.get_label_position()
134141
ifnotss.is_first_col():# Remove left label/ticklabels/offsettext.

‎lib/matplotlib/figure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,10 +1909,10 @@ def _do_layout(gs, mosaic, unique_ids, nested):
19091909
foraxinret.values():
19101910
ifsharex:
19111911
ax.sharex(ax0)
1912-
ax._label_outer_xaxis()
1912+
ax._label_outer_xaxis(check_patch=True)
19131913
ifsharey:
19141914
ax.sharey(ax0)
1915-
ax._label_outer_yaxis()
1915+
ax._label_outer_yaxis(check_patch=True)
19161916
fork,axinret.items():
19171917
ifisinstance(k,str):
19181918
ax.set_label(k)

‎lib/matplotlib/gridspec.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,12 @@ def subplots(self, *, sharex=False, sharey=False, squeeze=True,
306306
self[row,col],**subplot_kw)
307307

308308
# turn off redundant tick labeling
309-
ifall(ax.name=="rectilinear"foraxinaxarr.flat):
310-
ifsharexin ["col","all"]:
311-
foraxinaxarr.flat:
312-
ax._label_outer_xaxis()
313-
ifshareyin ["row","all"]:
314-
foraxinaxarr.flat:
315-
ax._label_outer_yaxis()
309+
ifsharexin ["col","all"]:
310+
foraxinaxarr.flat:
311+
ax._label_outer_xaxis(check_patch=True)
312+
ifshareyin ["row","all"]:
313+
foraxinaxarr.flat:
314+
ax._label_outer_yaxis(check_patch=True)
316315

317316
ifsqueeze:
318317
# Discarding unneeded dimensions that equal 1. If we only have one

‎lib/matplotlib/tests/test_polar.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,15 @@ def test_remove_shared_polar(fig_ref, fig_test):
396396

397397
deftest_shared_polar_keeps_ticklabels():
398398
fig,axs=plt.subplots(
399-
2,2,subplot_kw=dict(projection="polar"),sharex=True,sharey=True)
399+
2,2,subplot_kw={"projection":"polar"},sharex=True,sharey=True)
400400
fig.canvas.draw()
401401
assertaxs[0,1].xaxis.majorTicks[0].get_visible()
402402
assertaxs[0,1].yaxis.majorTicks[0].get_visible()
403+
fig,axs=plt.subplot_mosaic(
404+
"ab\ncd",subplot_kw={"projection":"polar"},sharex=True,sharey=True)
405+
fig.canvas.draw()
406+
assertaxs["b"].xaxis.majorTicks[0].get_visible()
407+
assertaxs["b"].yaxis.majorTicks[0].get_visible()
403408

404409

405410
deftest_axvline_axvspan_do_not_modify_rlims():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp