diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index a659507b9b08..137128c9c72b 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -1145,8 +1145,10 @@ def get_tightbbox(self, renderer): bb = [] for a in [self.label, self.offsetText]: - if a.get_visible(): - bb.append(a.get_window_extent(renderer)) + bbox = a.get_window_extent(renderer) + if (np.isfinite(bbox.width) and np.isfinite(bbox.height) and + a.get_visible()): + bb.append(bbox) bb.extend(ticklabelBoxes) bb.extend(ticklabelBoxes2)