Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite0a20cc

Browse files
committed
copy a bbox function to axesBase from figure
1 parent3ade95b commite0a20cc

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+
nameforname,axisinself.axes._axis_map.items()
2954+
ifnameinself.figure._align_label_groupsandaxisisself]
2955+
iflen(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+
foraxingrouper.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+
returnbboxes,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]fortitleintitles)
3032+
# TODO: and for titles in sibling axes according to grouper
30063033
fortitleintitles:
30073034
# now line up all the titles at the highest baseline.
30083035
x,_=title.get_position()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp