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""" 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): """