File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 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):
928928 self .stale = True
929929 self ._localaxes .remove (ax )
930930
931+ # Break link between any shared axes
931932 for name in ax ._axis_names :
932933 last_ax = _break_share_link (ax , ax ._shared_axes [name ])
933934 if last_ax is not None :
934935 _reset_locators_and_formatters (getattr (last_ax , f"{ name } axis" ))
935936
937+ # Break link between any twinned axes
938+ _break_share_link (ax , ax ._twinned_axes )
939+
936940 # Note: in the docstring below, the newlines in the examples after the
937941 # calls to legend() allow replacing it with figlegend() to generate the
938942 # docstring of pyplot.figlegend.
Original file line number Diff line number Diff line change @@ -4664,6 +4664,21 @@ def test_spectrum():
46644664 ax .set (xlabel = "" , ylabel = "" )
46654665
46664666
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+
46674682@image_comparison (['twin_spines.png' ], remove_text = True )
46684683def test_twin_spines ():
46694684
You can’t perform that action at this time.
0 commit comments