@@ -1268,7 +1268,8 @@ def sharex(self, other):
12681268 another Axes. Note that it is not possible to unshare axes.
12691269 """
12701270 _api .check_isinstance (_AxesBase , other = other )
1271- if self ._sharex is not None and other is not self ._sharex :
1271+ siblings = self ._shared_axes ["x" ]
1272+ if self ._is_xaxis_shared () is not None and other is not self ._sharex :
12721273 raise ValueError ("x-axis is already shared" )
12731274 self ._shared_axes ["x" ].join (self , other )
12741275 self ._sharex = other
@@ -1297,6 +1298,14 @@ def sharey(self, other):
12971298 self .set_ylim (y0 , y1 , emit = False , auto = other .get_autoscaley_on ())
12981299 self .yaxis ._scale = other .yaxis ._scale
12991300
1301+ def _is_xaxis_shared (self ):
1302+ """Return whether the x-axis is shared with any other Axes."""
1303+ return bool (self ._shared_axes ["x" ].get_siblings (include_self = False ))
1304+
1305+ def _is_yaxis_shared (self ):
1306+ """Return whether the y-axis is shared with any other Axes."""
1307+ return bool (self ._shared_axes ["Y" ].get_siblings (include_self = False ))
1308+
13001309 def __clear (self ):
13011310 """Clear the Axes."""
13021311 # The actual implementation of clear() as long as clear() has to be
@@ -1406,10 +1415,10 @@ def __clear(self):
14061415 self .xaxis .set_clip_path (self .patch )
14071416 self .yaxis .set_clip_path (self .patch )
14081417
1409- if self ._sharex is not None :
1418+ if self ._is_xaxis_shared () :
14101419 self .xaxis .set_visible (xaxis_visible )
14111420 self .patch .set_visible (patch_visible )
1412- if self ._sharey is not None :
1421+ if self ._is_yaxis_shared () :
14131422 self .yaxis .set_visible (yaxis_visible )
14141423 self .patch .set_visible (patch_visible )
14151424
@@ -1700,12 +1709,21 @@ def set_aspect(self, aspect, adjustable=None, anchor=None, share=False):
17001709 share : bool, default: False
17011710 If ``True``, apply the settings to all shared Axes.
17021711
1712+ Notes
1713+ -----
1714+ The aspect will require an update of the Axes position or limits (which
1715+ one depends on *adjustable*). This update is applied lazily, the latest
1716+ when the figure is drawn. Use `.apply_aspect` to force an update.
1717+
17031718 See Also
17041719 --------
17051720 matplotlib.axes.Axes.set_adjustable
17061721 Set how the Axes adjusts to achieve the required aspect ratio.
17071722 matplotlib.axes.Axes.set_anchor
17081723 Set the position in case of extra space.
1724+ matplotlib.axes.Axes.apply_aspect
1725+ Force the update required to meet the aspect ratio to happen
1726+ immediately.
17091727 """
17101728 if cbook ._str_equal (aspect , 'equal' ):
17111729 aspect = 1
0 commit comments