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

Skip to content

Commit 292a40b

Browse files
committed
Merge pull request matplotlib#4776 from ericmjl/mep12-scatter_masked.py
mep12 on scatter_masked.py
2 parents f7a5786 + 9e33f89 commit 292a40b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
#!/usr/bin/env python
2-
from pylab import *
1+
import matplotlib.pyplot as plt
2+
import numpy as np
33

44
N = 100
55
r0 = 0.6
6-
x = 0.9*rand(N)
7-
y = 0.9*rand(N)
8-
area = pi*(10 * rand(N))**2 # 0 to 10 point radiuses
9-
c = sqrt(area)
10-
r = sqrt(x*x + y*y)
11-
area1 = ma.masked_where(r < r0, area)
12-
area2 = ma.masked_where(r >= r0, area)
13-
scatter(x, y, s=area1, marker='^', c=c, hold='on')
14-
scatter(x, y, s=area2, marker='o', c=c)
6+
x = 0.9*np.random.rand(N)
7+
y = 0.9*np.random.rand(N)
8+
area = np.pi*(10 * np.random.rand(N))**2 # 0 to 10 point radiuses
9+
c = np.sqrt(area)
10+
r = np.sqrt(x*x + y*y)
11+
area1 = np.ma.masked_where(r < r0, area)
12+
area2 = np.ma.masked_where(r >= r0, area)
13+
plt.scatter(x, y, s=area1, marker='^', c=c, hold='on')
14+
plt.scatter(x, y, s=area2, marker='o', c=c)
1515
# Show the boundary between the regions:
16-
theta = arange(0, pi/2, 0.01)
17-
plot(r0*cos(theta), r0*sin(theta))
16+
theta = np.arange(0, np.pi/2, 0.01)
17+
plt.plot(r0*np.cos(theta), r0*np.sin(theta))
1818

19-
show()
19+
plt.show()

0 commit comments

Comments
 (0)