Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 98b75d0

Browse files
committed
Fix matplotlib#1799: path collections with NaNs in the path cause exceptions in vector backends.
1 parent c7da07d commit 98b75d0

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ def _iter_collection(self, gc, master_transform, all_transforms,
372372
xp, yp = transform.transform_point((0, 0))
373373
xo = -(xp - xo)
374374
yo = -(yp - yo)
375+
if not (np.isfinite(xo) and np.isfinite(yo)):
376+
continue
375377
if Nfacecolors:
376378
rgbFace = facecolors[i % Nfacecolors]
377379
if Nedgecolors:

lib/matplotlib/tests/test_scale.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
from __future__ import print_function
22

3-
from matplotlib.testing.decorators import image_comparison
3+
from matplotlib.testing.decorators import image_comparison, cleanup
44
import matplotlib.pyplot as plt
5+
import numpy as np
6+
import io
57

68

79
@image_comparison(baseline_images=['log_scales'], remove_text=True)
810
def test_log_scales():
911
ax = plt.subplot(122, yscale='log', xscale='symlog')
10-
12+
1113
ax.axvline(24.1)
12-
ax.axhline(24.1)
14+
ax.axhline(24.1)
15+
16+
17+
@cleanup
18+
def test_log_scatter():
19+
"""Issue #1799"""
20+
fig, ax = plt.subplots(1)
21+
22+
x = np.arange(10)
23+
y = np.arange(10) - 1
24+
25+
ax.scatter(x, y)
26+
27+
buf = io.BytesIO()
28+
fig.savefig(buf, format='pdf')
29+
30+
buf = io.BytesIO()
31+
fig.savefig(buf, format='eps')
32+
33+
buf = io.BytesIO()
34+
fig.savefig(buf, format='svg')

0 commit comments

Comments
 (0)