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

Skip to content

Commit 3f19e75

Browse files
committed
Merge remote-tracking branch 'pipping/master'
Conflicts: examples/api/scatter_piecharts.py White space induced conflicts Conflicts: examples/api/scatter_piecharts.py
1 parent efa3434 commit 3f19e75

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

examples/api/scatter_piecharts.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,40 @@
88
import matplotlib.pyplot as plt
99

1010
# 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%
1313

1414
# define some sizes of the scatter marker
15-
sizes = [60,80,120]
15+
sizes = [60, 80, 120]
1616

1717
# calculate the points of the first pie marker
1818
#
1919
# these are just the origin (0,0) +
2020
# some points on a circle cos,sin
2121
x = [0] + np.cos(np.linspace(0, 2*math.pi*r1, 10)).tolist()
2222
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))
2426

2527
# ...
2628
x = [0] + np.cos(np.linspace(2*math.pi*r1, 2*math.pi*r2, 10)).tolist()
2729
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))
2932

3033
x = [0] + np.cos(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
3134
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))
3437

3538
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+
3947
plt.show()

0 commit comments

Comments
 (0)