Skip to content

Commit 304ddd3

Browse files
committed
Fix problem with legend if data has NaN's
If data has NaN's and plot has a legend, matplotlib throws the following RuntimeWarning: ...\matplotlib\transforms.py:651: RuntimeWarning: invalid value encountered in sign
1 parent 76951f0 commit 304ddd3

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/matplotlib/transforms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ def count_contains(self, vertices):
647647
if len(vertices) == 0:
648648
return 0
649649
vertices = np.asarray(vertices)
650+
vertices = vertices[~np.isnan(np.sum(vertices, 1)), :] # handle NaN's
650651
x0, y0, x1, y1 = self._get_extents()
651652
dx0 = np.sign(vertices[:, 0] - x0)
652653
dy0 = np.sign(vertices[:, 1] - y0)

0 commit comments

Comments
 (0)