Skip to content

Commit d244c3f

Browse files
domspadjenshnielsen
authored andcommitted
to plt and np
1 parent 09f2577 commit d244c3f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# use masked arrays to plot a line with different colors by y-value
2-
from numpy import logical_or, arange, sin, pi
3-
from numpy import ma
4-
from matplotlib.pyplot import plot, show
2+
import numpy as np
3+
import matplotlib.pyplot as plt
54

6-
t = arange(0.0, 2.0, 0.01)
7-
s = sin(2*pi*t)
5+
t = np.arange(0.0, 2.0, 0.01)
6+
s = np.sin(2*np.pi*t)
87

98
upper = 0.77
109
lower = -0.77
1110

1211

13-
supper = ma.masked_where(s < upper, s)
14-
slower = ma.masked_where(s > lower, s)
15-
smiddle = ma.masked_where(logical_or(s < lower, s > upper), s)
12+
supper = np.ma.masked_where(s < upper, s)
13+
slower = np.ma.masked_where(s > lower, s)
14+
smiddle = np.ma.masked_where(np.logical_or(s < lower, s > upper), s)
1615

17-
plot(t, slower, 'r', t, smiddle, 'b', t, supper, 'g')
18-
show()
16+
plt.plot(t, slower, 'r', t, smiddle, 'b', t, supper, 'g')
17+
plt.show()

0 commit comments

Comments
 (0)