diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index f30572382fe9..f0dd963fe477 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -1042,6 +1042,8 @@ def get_window_extent(self, renderer=None, dpi=None): return bbox def get_tightbbox(self, renderer=None): + if not self.get_visible() or self.get_text() == "": + return Bbox.null() # Exclude text at data coordinates outside the valid domain of the axes # scales (e.g., negative coordinates with a log scale). if (self.axes