From 5902fcea4c1d8ca2666d3d8ad5199bd09ccd797f Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 19 Jan 2017 23:15:24 +0000 Subject: [PATCH 1/2] If text location isn't finite, set it to not visible --- lib/matplotlib/text.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 9e2d8be26842..214af64dfc3d 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -1154,6 +1154,8 @@ def set_position(self, xy): """ self.set_x(xy[0]) self.set_y(xy[1]) + if not np.all(np.isfinite(xy)): + self.set_visible(False) def set_x(self, x): """ From 0560b19a7c4107235380220649a8f948c9237ae7 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 19 Jan 2017 23:20:27 +0000 Subject: [PATCH 2/2] Add test for logit scale and tight_layout --- lib/matplotlib/tests/test_scale.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/matplotlib/tests/test_scale.py b/lib/matplotlib/tests/test_scale.py index fc840ba5c429..052923fc7bfe 100644 --- a/lib/matplotlib/tests/test_scale.py +++ b/lib/matplotlib/tests/test_scale.py @@ -28,6 +28,16 @@ def test_logit_scales(): ax.grid(True) +@cleanup +def test_logit_tight_layout(): + # Check that logit scale works with tight layout + fig, axs = plt.subplots(2, 2) + + axs[1, 1].set_yscale('logit') + plt.tight_layout() + plt.draw() + + @cleanup def test_log_scatter(): """Issue #1799"""