Skip to content

Commit 73866ba

Browse files
committed
MNT : simplified Annotation.get_window_extent
- match the behavior of text for invisible - simplify logic a bit (always use bbox back from Text)
1 parent 29b578c commit 73866ba

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lib/matplotlib/text.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -2100,24 +2100,20 @@ def get_window_extent(self, renderer=None):
21002100
irrelevant.
21012101
21022102
'''
2103+
if not self.get_visible():
2104+
return Bbox.unit()
21032105
arrow = self.arrow
21042106
arrow_patch = self.arrow_patch
21052107

21062108
text_bbox = Text.get_window_extent(self, renderer=renderer)
2107-
if text_bbox.width == 0.0 and text_bbox.height == 0.0:
2108-
bboxes = []
2109-
else:
2110-
bboxes = [text_bbox]
2109+
bboxes = [text_bbox]
21112110

21122111
if self.arrow is not None:
21132112
bboxes.append(arrow.get_window_extent(renderer=renderer))
21142113
elif self.arrow_patch is not None:
21152114
bboxes.append(arrow_patch.get_window_extent(renderer=renderer))
21162115

2117-
if len(bboxes) == 0:
2118-
return Bbox.from_bounds(self._x, self._y, 0.0, 0.0)
2119-
else:
2120-
return Bbox.union(bboxes)
2116+
return Bbox.union(bboxes)
21212117

21222118

21232119
docstring.interpd.update(Annotation=Annotation.__init__.__doc__)

0 commit comments

Comments
 (0)