Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 111b842

Browse filesBrowse files
committed
Merge pull request #4811 from ericmjl/nan_test.py-MEP12
nan_test.py mep12
2 parents db4b970 + 730667d commit 111b842
Copy full SHA for 111b842

File tree

Expand file treeCollapse file tree

1 file changed

+19
-21
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-21
lines changed

‎examples/pylab_examples/nan_test.py

Copy file name to clipboard
+19-21Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.