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

Skip to content

Commit 4a02596

Browse files
committed
MEP12 chagnes on nan_test.py
1 parent db4b970 commit 4a02596

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

examples/pylab_examples/nan_test.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
1-
#!/usr/bin/env python
21
"""
32
Example: simple line plots with NaNs inserted.
43
"""
5-
from pylab import *
64
import numpy as np
5+
import matplotlib.pyplot as plt
76

8-
t = arange(0.0, 1.0 + 0.01, 0.01)
9-
s = cos(2*2*pi*t)
10-
t[41:60] = NaN
11-
#t[50:60] = np.inf
7+
t = np.arange(0.0, 1.0 + 0.01, 0.01)
8+
s = np.cos(2*2*np.pi*t)
9+
t[41:60] = np.nan
1210

13-
subplot(2, 1, 1)
14-
plot(t, s, '-', lw=2)
11+
plt.subplot(2, 1, 1)
12+
plt.plot(t, s, '-', lw=2)
1513

16-
xlabel('time (s)')
17-
ylabel('voltage (mV)')
18-
title('A sine wave with a gap of NaNs between 0.4 and 0.6')
19-
grid(True)
14+
plt.xlabel('time (s)')
15+
plt.ylabel('voltage (mV)')
16+
plt.title('A sine wave with a gap of NaNs between 0.4 and 0.6')
17+
plt.grid(True)
2018

21-
subplot(2, 1, 2)
22-
t[0] = NaN
23-
t[-1] = NaN
24-
plot(t, s, '-', lw=2)
25-
title('Also with NaN in first and last point')
19+
plt.subplot(2, 1, 2)
20+
t[0] = np.nan
21+
t[-1] = np.nan
22+
plt.plot(t, s, '-', lw=2)
23+
plt.title('Also with NaN in first and last point')
2624

27-
xlabel('time (s)')
28-
ylabel('more nans')
29-
grid(True)
25+
plt.xlabel('time (s)')
26+
plt.ylabel('more nans')
27+
plt.grid(True)
3028

31-
show()
29+
plt.show()

0 commit comments

Comments
 (0)