Skip to content

Commit

Permalink
Fix scaling of custom markers
Browse files Browse the repository at this point in the history
See also #3441.
  • Loading branch information
epipping committed Sep 1, 2014
1 parent c9eb4df commit 554e412
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions examples/api/scatter_piecharts.py
Expand Up @@ -21,19 +21,24 @@
x = [0] + np.cos(np.linspace(0, 2*math.pi*r1, 10)).tolist()
y = [0] + np.sin(np.linspace(0, 2*math.pi*r1, 10)).tolist()
xy1 = list(zip(x,y))
s1 = max(max(x),max(y))

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

x = [0] + np.cos(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
y = [0] + np.sin(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
xy3 = list(zip(x,y))

s3 = max(max(x),max(y))

fig, ax = plt.subplots()
ax.scatter( np.arange(3), np.arange(3), marker=(xy1,0), s=sizes, facecolor='blue' )
ax.scatter( np.arange(3), np.arange(3), marker=(xy2,0), s=sizes, facecolor='green' )
ax.scatter( np.arange(3), np.arange(3), marker=(xy3,0), s=sizes, facecolor='red' )
ax.scatter( np.arange(3), np.arange(3), marker=(xy1,0),
s=[ s1*s1*x for x in sizes ], facecolor='blue' )
ax.scatter( np.arange(3), np.arange(3), marker=(xy2,0),
s=[ s2*s2*x for x in sizes ], facecolor='green' )
ax.scatter( np.arange(3), np.arange(3), marker=(xy3,0),
s=[ s3*s3*x for x in sizes ], facecolor='red' )
plt.show()

0 comments on commit 554e412

Please sign in to comment.