8000 mep12 on masked_demo.py · matplotlib/matplotlib@d569193 · GitHub
[go: up one dir, main page]

Skip to content

Commit d569193

Browse files
committed
mep12 on masked_demo.py
1 parent d265a6e commit d569193

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
#!/usr/bin/env python
21
'''
32
Plot lines with points masked out.
43
54
This would typically be used with gappy data, to
65
break the line at the data gaps.
76
'''
87

9-
from pylab import *
8+
import matplotlib.pyplot as plt
9+
import numpy as np
1010

11-
x = ma.arange(0, 2*pi, 0.02)
12-
y = ma.sin(x)
13-
y1 = sin(2*x)
14-
y2 = sin(3*x)
15-
ym1 = ma.masked_where(y1 > 0.5, y1)
16-
ym2 = ma.masked_where(y2 < -0.5, y2)
11+
x = np.arange(0, 2*np.pi, 0.02)
12+
y = np.sin(x)
13+
y1 = np.sin(2*x)
14+
y2 = np.sin(3*x)
15+
ym1 = np.ma.masked_where(y1 > 0.5, y1)
16+
ym2 = np.ma.masked_where(y2 < -0.5, y2)
1717

18-
lines = plot(x, y, 'r', x, ym1, 'g', x, ym2, 'bo')
19-
setp(lines[0], linewidth=4)
20-
setp(lines[1], linewidth=2)
21-
setp(lines[2], markersize=10)
18+
lines = plt.plot(x, y, 'r', x, ym1, 'g', x, ym2, 'bo')
19+
plt.setp(lines[0], linewidth=4)
20+
plt.setp(lines[1], linewidth=2)
21+
plt.setp(lines[2], markersize=10)
2222

23-
legend(('No mask', 'Masked if > 0.5', 'Masked if < -0.5'),
24-
loc='upper right')
25-
title('Masked line demo')
26-
show()
23+
plt.legend(('No mask', 'Masked if > 0.5', 'Masked if < -0.5'),
24+
loc='upper right')
25+
plt.title('Masked line demo')
26+
plt.show()

0 commit comments

Comments
 (0)
0