Update marker sizes of a scatter plot

断了今生、忘了曾经 提交于 2019-12-02 03:52:44
CT Zhu

Yes it is doable, with using a magic method (_size). Use it with caution, as it may become broken in future releases:

from matplotlib import pyplot as plt
import numpy as np

x, y=range(10), range(10)
sca=plt.scatter(x,y)
raw_input()
sca._sizes=(5+np.arange(10))*10 #you can set you markers to different sizes
plt.draw()

The method to update the sizes of the scatter points is called .set_sizes()

scat = plt.scatter(x,y)
scat.set_sizes(sizes)

where sizes must be an array or list of same length as x and y.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!