@@ -2454,6 +2454,37 @@ def _range_tightbbox(self, s):
2454
2454
else :
2455
2455
return bbox .ymin , bbox .ymax
2456
2456
2457
+ def _unshare (self , * , which : str ):
2458
+ """
2459
+ Remove this Axes from the shared Grouper for the given axis ('x', 'y', 'z', or 'view').
2460
+ Note this isolates the axis and does not preserve the transitivity of sharing.
2461
+ """
2462
+ if which not in self ._shared_axes :
2463
+ warnings ._warn_ultraplot (f"Axis { which } is not shared" )
2464
+ return
2465
+ if which in "xy" :
2466
+ setattr (self , f"_share{ which } " , None ) # essential
2467
+ # Note _scale is also set when calling sharex or y.
2468
+ # I think it is fine to leave it as otherwise we would
2469
+ # need to determine the scale, which may get messy.
2470
+
2471
+ grouper = self ._shared_axes [which ]
2472
+ siblings = list (grouper .get_siblings (self ))
2473
+ for sibling in siblings :
2474
+ if sibling is not self :
2475
+ # Unshare by removing them from the grouper
2476
+ grouper .remove (sibling )
2477
+ sibling ._shared_axes [which ].remove (self )
2478
+ # To be safe let's remove this
2479
+ self ._shared_axes [which ].remove (sibling )
2480
+ if which in "xy" :
2481
+ setattr (sibling , f"_share{ which } " , None )
2482
+ this_ax = getattr (self , f"{ which } axis" )
2483
+ sib_ax = getattr (sibling , f"{ which } axis" )
2484
+ # Reset formatters
2485
+ this_ax .major = copy .deepcopy (this_ax .major )
2486
+ this_ax .minor = copy .deepcopy (this_ax .minor )
2487
+
2457
2488
def _sharex_setup (self , sharex , ** kwargs ):
2458
2489
"""
2459
2490
Configure x-axis sharing for panels. See also `~CartesianAxes._sharex_setup`.
0 commit comments