From aa5537af653263ff6ed124d2f634d6e372584efa Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 10 Jun 2018 08:22:38 -0700 Subject: [PATCH] FIX: don't include text at -inf in bbox --- lib/matplotlib/axis.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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)