8000 Fix scaling of custom markers · matplotlib/matplotlib@554e412 · GitHub
[go: up one dir, main page]

Skip to content

Commit 554e412

Browse files
committed
Fix scaling of custom markers
See also #3441.
1 parent c9eb4df commit 554e412

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

examples/api/scatter_piecharts.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,24 @@
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()
2323
xy1 = list(zip(x,y))
24+
s1 = max(max(x),max(y))
2425

2526
# ...
2627
x = [0] + np.cos(np.linspace(2*math.pi*r1, 2*math.pi*r2, 10)).tolist()
2728
y = [0] + np.sin(np.linspace(2*math.pi*r1, 2*math.pi*r2, 10)).tolist()
2829
xy2 = list(zip(x,y))
30+
s2 = max(max(x),max(y))
2931

3032
x = [0] + np.cos(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
3133
y = [0] + np.sin(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
3234
xy3 = list(zip(x,y))
33-
35+
s3 = max(max(x),max(y))
3436

3537
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' )
38+
ax.scatter( np.arange(3), np.arange(3), marker=(xy1,0),
39+
s=[ s1*s1*x for x in sizes ], facecolor='blue' )
40+
ax.scatter( np.arange(3), np.arange(3), marker=(xy2,0),
41+
s=[ s2*s2*x for x in sizes ], facecolor='green' )
42+
ax.scatter( np.arange(3), np.arange(3), marker=(xy3,0),
43+
s=[ s3*s3*x for x in sizes ], facecolor='red' )
3944
plt.show()

0 commit comments

Comments
 (0)
0