File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -928,11 +928,15 @@ def _break_share_link(ax, grouper):
928
928
self .stale = True
929
929
self ._localaxes .remove (ax )
930
930
931
+ # Break link between any shared axes
931
932
for name in ax ._axis_names :
932
933
last_ax = _break_share_link (ax , ax ._shared_axes [name ])
933
934
if last_ax is not None :
934
935
_reset_locators_and_formatters (getattr (last_ax , f"{ name } axis" ))
935
936
937
+ # Break link between any twinned axes
938
+ _break_share_link (ax , ax ._twinned_axes )
939
+
936
940
# Note: in the docstring below, the newlines in the examples after the
937
941
# calls to legend() allow replacing it with figlegend() to generate the
938
942
# docstring of pyplot.figlegend.
Original file line number Diff line number Diff line change @@ -4664,6 +4664,21 @@ def test_spectrum():
4664
4664
ax .set (xlabel = "" , ylabel = "" )
4665
4665
4666
4666
4667
+ @check_figures_equal (extensions = ['png' ])
4668
+ def test_twin_remove (fig_test , fig_ref ):
4669
+ ax_test = fig_test .add_subplot ()
4670
+ ax_twinx = ax_test .twinx ()
4671
+ ax_twiny = ax_test .twiny ()
4672
+ ax_twinx .remove ()
4673
+ ax_twiny .remove ()
4674
+
4675
+ ax_ref = fig_ref .add_subplot ()
4676
+ # Ideally we also undo tick changes when calling ``remove()``, but for now
4677
+ # manually set the ticks of the reference image to match the test image
4678
+ ax_ref .xaxis .tick_bottom ()
4679
+ ax_ref .yaxis .tick_left ()
4680
+
4681
+
4667
4682
@image_comparison (['twin_spines.png' ], remove_text = True )
4668
4683
def test_twin_spines ():
4669
4684
You can’t perform that action at this time.
0 commit comments