From 98b75d050b3ea0b414f83456a77e73839f8c64cb Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Thu, 7 Mar 2013 11:38:48 -0500 Subject: [PATCH] Fix #1799: path collections with NaNs in the path cause exceptions in vector backends. --- lib/matplotlib/backend_bases.py | 2 ++ lib/matplotlib/tests/test_scale.py | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 978a13c032c0..18046336741d 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -372,6 +372,8 @@ def _iter_collection(self, gc, master_transform, all_transforms, xp, yp = transform.transform_point((0, 0)) xo = -(xp - xo) yo = -(yp - yo) + if not (np.isfinite(xo) and np.isfinite(yo)): + continue if Nfacecolors: rgbFace = facecolors[i % Nfacecolors] if Nedgecolors: diff --git a/lib/matplotlib/tests/test_scale.py b/lib/matplotlib/tests/test_scale.py index fd705834fa26..4a582bfedeae 100644 --- a/lib/matplotlib/tests/test_scale.py +++ b/lib/matplotlib/tests/test_scale.py @@ -1,12 +1,34 @@ from __future__ import print_function -from matplotlib.testing.decorators import image_comparison +from matplotlib.testing.decorators import image_comparison, cleanup import matplotlib.pyplot as plt +import numpy as np +import io @image_comparison(baseline_images=['log_scales'], remove_text=True) def test_log_scales(): ax = plt.subplot(122, yscale='log', xscale='symlog') - + ax.axvline(24.1) - ax.axhline(24.1) \ No newline at end of file + ax.axhline(24.1) + + +@cleanup +def test_log_scatter(): + """Issue #1799""" + fig, ax = plt.subplots(1) + + x = np.arange(10) + y = np.arange(10) - 1 + + ax.scatter(x, y) + + buf = io.BytesIO() + fig.savefig(buf, format='pdf') + + buf = io.BytesIO() + fig.savefig(buf, format='eps') + + buf = io.BytesIO() + fig.savefig(buf, format='svg')