@@ -1569,9 +1569,8 @@ def set_ticks(self, ticks, minor=False):
1569
1569
1570
1570
def _update_label_position (self , bboxes , bboxes2 ):
1571
1571
"""
1572
- Update the label position based on the sequence of bounding
1573
- boxes of all the ticklabels or using the axis spines if no
1574
- ticklabels are present
1572
+ Update the label position based on the the bounding box enclosing
1573
+ all the ticklabels and axis spine
1575
1574
"""
1576
1575
raise NotImplementedError ('Derived must override' )
1577
1576
@@ -1726,33 +1725,30 @@ def set_label_position(self, position):
1726
1725
1727
1726
def _update_label_position (self , bboxes , bboxes2 ):
1728
1727
"""
1729
- Update the label position based on the sequence of bounding
1730
- boxes of all the ticklabels or using the axis spines if no
1731
- ticklabels are present
1728
+ Update the label position based on the the bounding box enclosing
1729
+ all the ticklabels and axis spine
1732
1730
"""
1733
1731
if not self ._autolabelpos :
1734
1732
return
1735
1733
x , y = self .label .get_position ()
1736
1734
if self .label_position == 'bottom' :
1737
- if not len (bboxes ):
1738
- bottom = (self .axes .spines ['bottom' ].get_transform ().
1739
- transform_path (self .axes .spines ['bottom' ].
1740
- get_path ()).get_extents ().ymin )
1741
- else :
1742
- bbox = mtransforms .Bbox .union (bboxes )
1743
- bottom = bbox .y0
1735
+ spinebbox = (self .axes .spines ['bottom' ].get_transform ().
1736
+ transform_path (self .axes .spines ['bottom' ].
1737
+ get_path ()).get_extents ())
1738
+ bbox = mtransforms .Bbox .union (bboxes + [spinebbox ])
1739
+ bottom = bbox .y0
1740
+
1744
1741
self .label .set_position (
1745
1742
(x , bottom - self .labelpad * self .figure .dpi / 72.0 )
1746
1743
)
1747
1744
1748
1745
else :
1749
- if not len (bboxes2 ):
1750
- top = (self .axes .spines ['top' ].get_transform ().
1751
- transform_path (self .axes .spines ['top' ].
1752
- get_path ()).get_extents ().ymax )
1753
- else :
1754
- bbox = mtransforms .Bbox .union (bboxes2 )
1755
- top = bbox .y1
1746
+ spinebbox = (self .axes .spines ['top' ].get_transform ().
1747
+ transform_path (self .axes .spines ['top' ].
1748
+ get_path ()).get_extents ())
1749
+ bbox = mtransforms .Bbox .union (bboxes2 + [spinebbox ])
1750
+ top = bbox .y1
1751
+
1756
1752
self .label .set_position (
1757
1753
(x , top + self .labelpad * self .figure .dpi / 72.0 )
1758
1754
)
@@ -2037,34 +2033,29 @@ def set_label_position(self, position):
2037
2033
2038
2034
def _update_label_position (self , bboxes , bboxes2 ):
2039
2035
"""
2040
- Update the label position based on the sequence of bounding
2041
- boxes of all the ticklabels or using the axis spines if no
2042
- ticklabels are present
2036
+ Update the label position based on the the bounding box enclosing
2037
+ all the ticklabels and axis spine
2043
2038
"""
2044
2039
if not self ._autolabelpos :
2045
2040
return
2046
2041
x , y = self .label .get_position ()
2047
2042
if self .label_position == 'left' :
2048
- if not len (bboxes ):
2049
- left = (self .axes .spines ['left' ].get_transform ().
2050
- transform_path (self .axes .spines ['left' ].
2051
- get_path ()).get_extents ().xmin )
2052
- else :
2053
- bbox = mtransforms .Bbox .union (bboxes )
2054
- left = bbox .x0
2043
+ spinebbox = (self .axes .spines ['left' ].get_transform ().
2044
+ transform_path (self .axes .spines ['left' ].
2045
+ get_path ()).get_extents ())
2046
+ bbox = mtransforms .Bbox .union (bboxes + [spinebbox ])
2047
+ left = bbox .x0
2055
2048
2056
2049
self .label .set_position (
2057
2050
(left - self .labelpad * self .figure .dpi / 72.0 , y )
2058
2051
)
2059
2052
2060
2053
else :
2061
- if not len (bboxes2 ):
2062
- right = (self .axes .spines ['right' ].get_transform ().
2054
+ spinebbox = (self .axes .spines ['right' ].get_transform ().
2063
2055
transform_path (self .axes .spines ['right' ].
2064
- get_path ()).get_extents ().xmax )
2065
- else :
2066
- bbox = mtransforms .Bbox .union (bboxes2 )
2067
- right = bbox .x1
2056
+ get_path ()).get_extents ())
2057
+ bbox = mtransforms .Bbox .union (bboxes2 + [spinebbox ])
2058
+ right = bbox .x1
2068
2059
2069
2060
self .label .set_position (
2070
2061
(right + self .labelpad * self .figure .dpi / 72.0 , y )
0 commit comments