Update marker sizes of a scatter plot

五迷三道 提交于 2019-12-02 10:52:34

问题


A scatter plot object has a method called .set_array to update the colours of the markers and .set_offsets to update their position but how can I update the marker sizes?

I need this for fast real time plotting.


回答1:


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()




回答2:


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.



来源:https://stackoverflow.com/questions/24626583/update-marker-sizes-of-a-scatter-plot

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