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

Commit2d25e62

Browse files
committed
axes_grid1: make twin* not modify host axes
PR#4898 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-#4898 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 parentf7b88be commit2d25e62

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

‎doc/api/api_changes.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ This pages lists API changes for the most recent version of Matplotlib.
3636
next_api_changes/*
3737

3838

39+
API Changes for 3.1.0
40+
=====================
41+
42+
Changes to ``twin*`` methods in `~.mpl_toolkits.axes_grid1`
43+
-----------------------------------------------------------
44+
45+
Previously, calling ``twin``, ``twinx`` and ``twiny`` on
46+
`~.mpl_toolkits.axes_grid1` host axes would hide the host axes' own axis lines
47+
so that there is no overdrawing with the twin/parasite axes' axis lines. This
48+
could lead to surprising behavior in certain cases
49+
([#10748](https://github.com/matplotlib/matplotlib/issues/10748)), so the
50+
logic has now been reversed. I.e., host axis lines are kept and twin/parasite
51+
axis lines hidden. This may break code which relies on the specifics of
52+
host/parasite axis line visibility.
53+
3954
API Changes for 3.0.1
4055
=====================
4156

‎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