@@ -1079,15 +1079,15 @@ def _get_tick_bboxes(self, ticks, renderer):
10791079 [tick .label2 .get_window_extent (renderer )
10801080 for tick in ticks if tick .label2 .get_visible ()])
10811081
1082- def get_tightbbox (self , renderer , * , ignore_label = None ):
1082+ def get_tightbbox (self , renderer , * , for_layout_only = False ):
10831083 """
10841084 Return a bounding box that encloses the axis. It only accounts
10851085 tick labels, axis label, and offsetText.
10861086
1087- If ``ignore_label`` is 'x' , then the width of the label is collapsed
1088- to near zero. If 'y', then the height is collapsed to near zero. This
1089- is for tight/constrained_layout to be able to ignore too-long labels
1090- when doing their layout.
1087+ If *for_layout_only* is True , then the width of the label (if this
1088+ is an x-axis) or the height of the label (if this is a y-axis) is
1089+ collapsed to near zero. This allows tight/constrained_layout to ignore
1090+ too-long labels when doing their layout.
10911091 """
10921092 if not self .get_visible ():
10931093 return
@@ -1114,14 +1114,15 @@ def get_tightbbox(self, renderer, *, ignore_label=None):
11141114 if self .label .get_visible ():
11151115 bb = self .label .get_window_extent (renderer )
11161116 # for constrained/tight_layout, we want to ignore the label's
1117- # width because the adjustments they make can't be improved.
1117+ # width/height because the adjustments they make can't be improved.
11181118 # this code collapses the relevant direction
1119- if ignore_label == 'x' and bb .width > 0 :
1120- bb .x0 = (bb .x0 + bb .x1 ) / 2 - 0.5
1121- bb .x1 = bb .x0 + 1.0
1122- elif ignore_label == 'y' and bb .height > 0 :
1123- bb .y0 = (bb .y0 + bb .y1 ) / 2 - 0.5
1124- bb .y1 = bb .y0 + 1.0
1119+ if for_layout_only :
1120+ if self .axis_name == "x" and bb .width > 0 :
1121+ bb .x0 = (bb .x0 + bb .x1 ) / 2 - 0.5
1122+ bb .x1 = bb .x0 + 1.0
1123+ if self .axis_name == "y" and bb .height > 0 :
1124+ bb .y0 = (bb .y0 + bb .y1 ) / 2 - 0.5
1125+ bb .y1 = bb .y0 + 1.0
11251126 bboxes .append (bb )
11261127 bboxes = [b for b in bboxes
11271128 if 0 < b .width < np .inf and 0 < b .height < np .inf ]
0 commit comments