From 49eed4fb16a807ef9e5c2615ca336010cddfc4e8 Mon Sep 17 00:00:00 2001 From: Marcos Duarte Date: Fri, 3 Oct 2014 17:53:21 -0300 Subject: [PATCH] Fix problem with legend if data has NaN's If data has NaN's and plot has a legend, matplotlib throws a RuntimeWarning on lines 651-654. Solution is ignore it. --- lib/matplotlib/transforms.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index 3df7ce3f1c97..2589fa0e2ac8 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -648,10 +648,11 @@ def count_contains(self, vertices): return 0 vertices = np.asarray(vertices) x0, y0, x1, y1 = self._get_extents() - dx0 = np.sign(vertices[:, 0] - x0) - dy0 = np.sign(vertices[:, 1] - y0) - dx1 = np.sign(vertices[:, 0] - x1) - dy1 = np.sign(vertices[:, 1] - y1) + with np.errstate(invalid='ignore'): + dx0 = np.sign(vertices[:, 0] - x0) + dy0 = np.sign(vertices[:, 1] - y0) + dx1 = np.sign(vertices[:, 0] - x1) + dy1 = np.sign(vertices[:, 1] - y1) inside = ((abs(dx0 + dx1) + abs(dy0 + dy1)) == 0) return np.sum(inside)