更新散点图的标记大小 [英] Update marker sizes of a scatter plot
本文介绍了更新散点图的标记大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
散点图对象具有一种名为 .set_array
的方法来更新标记的颜色,并使用一种 .set_offsets
来更新其位置的方法,但是如何更新标记的大小?
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.
推荐答案
是的,它是可行的,使用魔法方法 (_size
).请谨慎使用,因为它可能会在未来版本中损坏:
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()
这篇关于更新散点图的标记大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文