@@ -2941,6 +2941,32 @@ def handle_single_axis(
2941
2941
scaley , self ._shared_axes ["y" ], 'y' , self .yaxis , self ._ymargin ,
2942
2942
y_stickies , self .set_ybound )
2943
2943
2944
+ def _get_titles_siblings (self , renderer ):
2945
+ """
2946
+ Get the bounding boxes for this `.axis` and its siblings
2947
+ as set by `.Figure.align_titles`.
2948
+
2949
+ By default it just gets bboxes for self.
2950
+ """
2951
+ # Get the Grouper keeping track of title groups for this figure.
2952
+ axis_names = [
2953
+ name for name , axis in self .axes ._axis_map .items ()
2954
+ if name in self .figure ._align_label_groups and axis is self ]
2955
+ if len (axis_names ) != 1 :
2956
+ return [], []
2957
+ axis_name , = axis_names
2958
+ grouper = self .figure ._align_label_groups [axis_name ]
2959
+ bboxes = []
2960
+ bboxes2 = []
2961
+ # If we want to align labels from other Axes:
2962
+ for ax in grouper .get_siblings (self .axes ):
2963
+ axis = getattr (ax , f"{ axis_name } axis" )
2964
+ ticks_to_draw = axis ._update_ticks ()
2965
+ tlb , tlb2 = axis ._get_ticklabel_bboxes (ticks_to_draw , renderer )
2966
+ bboxes .extend (tlb )
2967
+ bboxes2 .extend (tlb2 )
2968
+ return bboxes , bboxes2
2969
+
2944
2970
def _update_title_position (self , renderer ):
2945
2971
"""
2946
2972
Update the title position based on the bounding box enclosing
@@ -3003,6 +3029,7 @@ def _update_title_position(self, renderer):
3003
3029
title .set_position ((x , y ))
3004
3030
3005
3031
ymax = max (title .get_position ()[1 ] for title in titles )
3032
+ # TODO: and for titles in sibling axes according to grouper
3006
3033
for title in titles :
3007
3034
# now line up all the titles at the highest baseline.
3008
3035
x , _ = title .get_position ()
0 commit comments