Skip to content

Commit e0a20cc

Browse files
committed
copy a bbox function to axesBase from figure
1 parent 3ade95b commit e0a20cc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,6 +2941,32 @@ def handle_single_axis(
29412941
scaley, self._shared_axes["y"], 'y', self.yaxis, self._ymargin,
29422942
y_stickies, self.set_ybound)
29432943

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+
29442970
def _update_title_position(self, renderer):
29452971
"""
29462972
Update the title position based on the bounding box enclosing
@@ -3003,6 +3029,7 @@ def _update_title_position(self, renderer):
30033029
title.set_position((x, y))
30043030

30053031
ymax = max(title.get_position()[1] for title in titles)
3032+
# TODO: and for titles in sibling axes according to grouper
30063033
for title in titles:
30073034
# now line up all the titles at the highest baseline.
30083035
x, _ = title.get_position()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy