|
1 |
| -#!/usr/bin/env python |
2 |
| -from pylab import * |
| 1 | +import matplotlib.pyplot as plt |
| 2 | +import numpy as np |
3 | 3 |
|
4 | 4 | N = 100
|
5 | 5 | 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) |
15 | 15 | # 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)) |
18 | 18 |
|
19 |
| -show() |
| 19 | +plt.show() |
0 commit comments