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

Skip to content

Commit 6f0fa53

Browse files
committed
Check for isfinite in get_path_extents.
This is part of an experiment to make nan and inf be ignored equally throughout plotting; it may turn out to be unnecessary, in which case it should be reverted for the sake of efficiency. svn path=/trunk/matplotlib/; revision=5981
1 parent 672e4b5 commit 6f0fa53

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

examples/pylab_examples/nan_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
Example: simple line plots with NaNs inserted.
44
"""
55
from pylab import *
6+
import numpy as np
67

78
t = arange(0.0, 1.0+0.01, 0.01)
89
s = cos(2*2*pi*t)
910
t[41:60] = NaN
11+
#t[50:60] = np.inf
1012

1113
subplot(2,1,1)
1214
plot(t, s, '-', lw=2)
@@ -20,6 +22,7 @@
2022
t[0] = NaN
2123
t[-1] = NaN
2224
plot(t, s, '-', lw=2)
25+
title('Also with NaN in first and last point')
2326

2427
xlabel('time (s)')
2528
ylabel('more nans')

src/_path.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ void get_path_extents(PathIterator& path, const agg::trans_affine& trans,
280280
{
281281
if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly)
282282
continue;
283+
if (MPL_notisfinite64(x) || MPL_notisfinite64(y))
284+
continue;
283285
if (x < *x0) *x0 = x;
284286
if (y < *y0) *y0 = y;
285287
if (x > *x1) *x1 = x;

0 commit comments

Comments
 (0)