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

Commit8f793f7

Browse files
committed
axes_grid1: make twin* not modify host axes
PR#4896 changed the behavior of twinx() and twiny() in axes_grid1 tomake them consistent with twin(). This commit inverts the "direction" ofconsistency and makes twin() behave like the pre-#4896 twinx() andtwiny() instead. This way, the API becomes less surprising: instead ofhiding certain host axes, twin* now keeps the host axes unmodified,while the parasite axes have their axis lines hidden instead.Unfortunately, this change breaks backwards-compatibility for coderelying on the specifics of host and parasite axes visibility.Helps with#10748.
1 parentd1060a8 commit8f793f7

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

‎lib/mpl_toolkits/axes_grid1/parasite_axes.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,15 @@ def twinx(self, axes_class=None):
249249
self.parasites.append(ax2)
250250
ax2._remove_method=self._remove_twinx
251251

252-
self.axis["right"].set_visible(False)
253-
254252
ax2.axis["right"].set_visible(True)
253+
ax2.axis["right"].toggle(all=True)
254+
ax2.axis["right"].line.set_visible(False)
255255
ax2.axis["left","top","bottom"].set_visible(False)
256256

257257
returnax2
258258

259259
def_remove_twinx(self,ax):
260260
self.parasites.remove(ax)
261-
self.axis["right"].set_visible(True)
262-
self.axis["right"].toggle(ticklabels=False,label=False)
263261

264262
deftwiny(self,axes_class=None):
265263
"""
@@ -278,17 +276,15 @@ def twiny(self, axes_class=None):
278276
self.parasites.append(ax2)
279277
ax2._remove_method=self._remove_twiny
280278

281-
self.axis["top"].set_visible(False)
282-
283279
ax2.axis["top"].set_visible(True)
280+
ax2.axis["top"].toggle(all=True)
281+
ax2.axis["top"].line.set_visible(False)
284282
ax2.axis["left","right","bottom"].set_visible(False)
285283

286284
returnax2
287285

288286
def_remove_twiny(self,ax):
289287
self.parasites.remove(ax)
290-
self.axis["top"].set_visible(True)
291-
self.axis["top"].toggle(ticklabels=False,label=False)
292288

293289
deftwin(self,aux_trans=None,axes_class=None):
294290
"""
@@ -313,15 +309,13 @@ def twin(self, aux_trans=None, axes_class=None):
313309
self.parasites.append(ax2)
314310
ax2._remove_method=self.parasites.remove
315311

316-
self.axis["top","right"].set_visible(False)
317-
318312
ax2.axis["top","right"].set_visible(True)
313+
ax2.axis["top","right"].toggle(all=True)
314+
ax2.axis["top","right"].line.set_visible(False)
319315
ax2.axis["left","bottom"].set_visible(False)
320316

321317
def_remove_method(h):
322318
self.parasites.remove(h)
323-
self.axis["top","right"].set_visible(True)
324-
self.axis["top","right"].toggle(ticklabels=False,label=False)
325319
ax2._remove_method=_remove_method
326320

327321
returnax2

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp