Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a92bf03

Browse files
committed
FIX: fix offset text for vertical colorbars
1 parent 075067c commit a92bf03

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/matplotlib/axis.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,8 +2380,13 @@ def _update_offset_text_position(self, bboxes, bboxes2):
23802380
Update the offset_text position based on the sequence of bounding
23812381
boxes of all the ticklabels
23822382
"""
2383-
x, y = self.offsetText.get_position()
2384-
top = self.axes.bbox.ymax
2383+
x, _ = self.offsetText.get_position()
2384+
if 'outline' in self.axes.spines:
2385+
# Special case for colorbars:
2386+
bbox = self.axes.spines['outline'].get_window_extent()
2387+
else:
2388+
bbox = self.axes.bbox
2389+
top = bbox.ymax
23852390
self.offsetText.set_position(
23862391
(x, top + self.OFFSETTEXTPAD * self.figure.dpi / 72)
23872392
)

0 commit comments

Comments
 (0)