@@ -1018,24 +1018,18 @@ def _set_artist_props(self, a):
10181018 a .set_figure (self .figure )
10191019
10201020 def get_ticklabel_extents (self , renderer ):
1021- """
1022- Get the extents of the tick labels on either side
1023- of the axes.
1024- """
1025-
1021+ """Get the extents of the tick labels on either side of the axes."""
10261022 ticks_to_draw = self ._update_ticks ()
1027- ticklabelBoxes , ticklabelBoxes2 = self ._get_tick_bboxes (ticks_to_draw ,
1028- renderer )
1029-
1030- if len (ticklabelBoxes ):
1031- bbox = mtransforms .Bbox .union (ticklabelBoxes )
1023+ tlb1 , tlb2 = self ._get_ticklabel_bboxes (ticks_to_draw , renderer )
1024+ if len (tlb1 ):
1025+ bbox1 = mtransforms .Bbox .union (tlb1 )
10321026 else :
1033- bbox = mtransforms .Bbox .from_extents (0 , 0 , 0 , 0 )
1034- if len (ticklabelBoxes2 ):
1035- bbox2 = mtransforms .Bbox .union (ticklabelBoxes2 )
1027+ bbox1 = mtransforms .Bbox .from_extents (0 , 0 , 0 , 0 )
1028+ if len (tlb2 ):
1029+ bbox2 = mtransforms .Bbox .union (tlb2 )
10361030 else :
10371031 bbox2 = mtransforms .Bbox .from_extents (0 , 0 , 0 , 0 )
1038- return bbox , bbox2
1032+ return bbox1 , bbox2
10391033
10401034 def _update_ticks (self ):
10411035 """
@@ -1080,7 +1074,7 @@ def _update_ticks(self):
10801074
10811075 return ticks_to_draw
10821076
1083- def _get_tick_bboxes (self , ticks , renderer ):
1077+ def _get_ticklabel_bboxes (self , ticks , renderer ):
10841078 """Return lists of bboxes for ticks' label1's and label2's."""
10851079 return ([tick .label1 .get_window_extent (renderer )
10861080 for tick in ticks if tick .label1 .get_visible ()],
@@ -1105,18 +1099,16 @@ def get_tightbbox(self, renderer, *, for_layout_only=False):
11051099 self ._update_label_position (renderer )
11061100
11071101 # go back to just this axis's tick labels
1108- ticklabelBoxes , ticklabelBoxes2 = self ._get_tick_bboxes (
1109- ticks_to_draw , renderer )
1102+ tlb1 , tlb2 = self ._get_ticklabel_bboxes (ticks_to_draw , renderer )
11101103
1111- self ._update_offset_text_position (ticklabelBoxes , ticklabelBoxes2 )
1104+ self ._update_offset_text_position (tlb1 , tlb2 )
11121105 self .offsetText .set_text (self .major .formatter .get_offset ())
11131106
11141107 bboxes = [
11151108 * (a .get_window_extent (renderer )
11161109 for a in [self .offsetText ]
11171110 if a .get_visible ()),
1118- * ticklabelBoxes ,
1119- * ticklabelBoxes2 ,
1111+ * tlb1 , * tlb2 ,
11201112 ]
11211113 # take care of label
11221114 if self .label .get_visible ():
@@ -1156,22 +1148,20 @@ def draw(self, renderer, *args, **kwargs):
11561148 renderer .open_group (__name__ , gid = self .get_gid ())
11571149
11581150 ticks_to_draw = self ._update_ticks ()
1159- ticklabelBoxes , ticklabelBoxes2 = self ._get_tick_bboxes (ticks_to_draw ,
1160- renderer )
1151+ tlb1 , tlb2 = self ._get_ticklabel_bboxes (ticks_to_draw , renderer )
11611152
11621153 for tick in ticks_to_draw :
11631154 tick .draw (renderer )
11641155
1165- # scale up the axis label box to also find the neighbors, not
1166- # just the tick labels that actually overlap note we need a
1167- # *copy* of the axis label box because we don't want to scale
1168- # the actual bbox
1156+ # Scale up the axis label box to also find the neighbors, not just the
1157+ # tick labels that actually overlap. We need a *copy* of the axis
1158+ # label box because we don't want to scale the actual bbox.
11691159
11701160 self ._update_label_position (renderer )
11711161
11721162 self .label .draw (renderer )
11731163
1174- self ._update_offset_text_position (ticklabelBoxes , ticklabelBoxes2 )
1164+ self ._update_offset_text_position (tlb1 , tlb2 )
11751165 self .offsetText .set_text (self .major .formatter .get_offset ())
11761166 self .offsetText .draw (renderer )
11771167
@@ -1878,7 +1868,7 @@ def _get_tick_boxes_siblings(self, renderer):
18781868 for ax in grouper .get_siblings (self .axes ):
18791869 axis = getattr (ax , f"{ axis_name } axis" )
18801870 ticks_to_draw = axis ._update_ticks ()
1881- tlb , tlb2 = axis ._get_tick_bboxes (ticks_to_draw , renderer )
1871+ tlb , tlb2 = axis ._get_ticklabel_bboxes (ticks_to_draw , renderer )
18821872 bboxes .extend (tlb )
18831873 bboxes2 .extend (tlb2 )
18841874 return bboxes , bboxes2
@@ -2144,19 +2134,19 @@ def get_text_heights(self, renderer):
21442134 """
21452135 bbox , bbox2 = self .get_ticklabel_extents (renderer )
21462136 # MGDTODO: Need a better way to get the pad
2147- padPixels = self .majorTicks [0 ].get_pad_pixels ()
2137+ pad_pixels = self .majorTicks [0 ].get_pad_pixels ()
21482138
21492139 above = 0.0
21502140 if bbox2 .height :
2151- above += bbox2 .height + padPixels
2141+ above += bbox2 .height + pad_pixels
21522142 below = 0.0
21532143 if bbox .height :
2154- below += bbox .height + padPixels
2144+ below += bbox .height + pad_pixels
21552145
21562146 if self .get_label_position () == 'top' :
2157- above += self .label .get_window_extent (renderer ).height + padPixels
2147+ above += self .label .get_window_extent (renderer ).height + pad_pixels
21582148 else :
2159- below += self .label .get_window_extent (renderer ).height + padPixels
2149+ below += self .label .get_window_extent (renderer ).height + pad_pixels
21602150 return above , below
21612151
21622152 def set_ticks_position (self , position ):
@@ -2407,19 +2397,19 @@ def set_offset_position(self, position):
24072397 def get_text_widths (self , renderer ):
24082398 bbox , bbox2 = self .get_ticklabel_extents (renderer )
24092399 # MGDTODO: Need a better way to get the pad
2410- padPixels = self .majorTicks [0 ].get_pad_pixels ()
2400+ pad_pixels = self .majorTicks [0 ].get_pad_pixels ()
24112401
24122402 left = 0.0
24132403 if bbox .width :
2414- left += bbox .width + padPixels
2404+ left += bbox .width + pad_pixels
24152405 right = 0.0
24162406 if bbox2 .width :
2417- right += bbox2 .width + padPixels
2407+ right += bbox2 .width + pad_pixels
24182408
24192409 if self .get_label_position () == 'left' :
2420- left += self .label .get_window_extent (renderer ).width + padPixels
2410+ left += self .label .get_window_extent (renderer ).width + pad_pixels
24212411 else :
2422- right += self .label .get_window_extent (renderer ).width + padPixels
2412+ right += self .label .get_window_extent (renderer ).width + pad_pixels
24232413 return left , right
24242414
24252415 def set_ticks_position (self , position ):
0 commit comments