|
8 | 8 | import matplotlib.pyplot as plt
|
9 | 9 |
|
10 | 10 | # first define the ratios
|
11 |
| -r1 = 0.2 # 20% |
12 |
| -r2 = r1 + 0.4 # 40% |
| 11 | +r1 = 0.2 # 20% |
| 12 | +r2 = r1 + 0.4 # 40% |
13 | 13 |
|
14 | 14 | # define some sizes of the scatter marker
|
15 |
| -sizes = [60,80,120] |
| 15 | +sizes = [60, 80, 120] |
16 | 16 |
|
17 | 17 | # calculate the points of the first pie marker
|
18 | 18 | #
|
19 | 19 | # these are just the origin (0,0) +
|
20 | 20 | # some points on a circle cos,sin
|
21 | 21 | x = [0] + np.cos(np.linspace(0, 2*math.pi*r1, 10)).tolist()
|
22 | 22 | y = [0] + np.sin(np.linspace(0, 2*math.pi*r1, 10)).tolist()
|
23 |
| -xy1 = list(zip(x,y)) |
| 23 | + |
| 24 | +xy1 = list(zip(x, y)) |
| 25 | +s1 = max(max(x), max(y)) |
24 | 26 |
|
25 | 27 | # ...
|
26 | 28 | x = [0] + np.cos(np.linspace(2*math.pi*r1, 2*math.pi*r2, 10)).tolist()
|
27 | 29 | y = [0] + np.sin(np.linspace(2*math.pi*r1, 2*math.pi*r2, 10)).tolist()
|
28 |
| -xy2 = list(zip(x,y)) |
| 30 | +xy2 = list(zip(x, y)) |
| 31 | +s2 = max(max(x), max(y)) |
29 | 32 |
|
30 | 33 | x = [0] + np.cos(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
|
31 | 34 | y = [0] + np.sin(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
|
32 |
| -xy3 = list(zip(x,y)) |
33 |
| - |
| 35 | +xy3 = list(zip(x, y)) |
| 36 | +s3 = max(max(x), max(y)) |
34 | 37 |
|
35 | 38 | fig, ax = plt.subplots()
|
36 |
| -ax.scatter( np.arange(3), np.arange(3), marker=(xy1,0), s=sizes, facecolor='blue' ) |
37 |
| -ax.scatter( np.arange(3), np.arange(3), marker=(xy2,0), s=sizes, facecolor='green' ) |
38 |
| -ax.scatter( np.arange(3), np.arange(3), marker=(xy3,0), s=sizes, facecolor='red' ) |
| 39 | +ax.scatter(np.arange(3), np.arange(3), marker=(xy1, 0), |
| 40 | + s=[s1*s1*_ for _ in sizes], facecolor='blue') |
| 41 | +ax.scatter(np.arange(3), np.arange(3), marker=(xy2, 0), |
| 42 | + s=[s2*s2*_ for _ in sizes], facecolor='green') |
| 43 | +ax.scatter(np.arange(3), np.arange(3), marker=(xy3, 0), |
| 44 | + s=[s3*s3*_ for _ in sizes], facecolor='red') |
| 45 | + |
| 46 | + |
39 | 47 | plt.show()
|
0 commit comments