1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > python for循环画图_通过for循环中更新的字典制作可滚动绘图 - python

python for循环画图_通过for循环中更新的字典制作可滚动绘图 - python

时间:2023-09-17 10:32:04

相关推荐

python for循环画图_通过for循环中更新的字典制作可滚动绘图 - python

我有一个由for循环更新的字典,我试图在键值对的数量不断更新的情况下绘制移动或滑动的图中的键值对,并且该图仅显示了该字典中的50个当前值。

到目前为止,我已经做出了:

for k,v in plot.items():

plt.barh(k,v , color=lue)

plt.pause(0.3)

plt.show()

问题在于值不断增加,图也不断增长。有什么方法可以显示字典中的最后50 k,v对,并继续更新绘图。我也尝试了一个功能:

def live_plotter(x_vec,y1_data,line1,identifier=\,pause_time=0.1):

if line1==[]:

# this is the call to matplotlib that allows dynamic plotting

plt.ion()

#fig = plt.figure(figsize=(13,6))

#ax = fig.add_subplot(111)

# create a variable for the line so we can later update it

line1, = plt.plot(x_vec,y1_data,-o, alpha=0.8)

#update plot label/title

plt.ylabel(Cross-correlation)

plt.title(Title: {}.format(identifier))

line1.set_data(x_vec,

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。