admin管理员组文章数量:1122832
trying to animate data of multiple trace using matplotlib animation but the result doesn't satisfy my request, I want to plot all trace of the steam simultaneously, but it draws only one trace each running time.?
from obspy import read
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
st=read('300/*')
st=st.select(component='Z')
tr0=st[0]
seed_ids={tr.stats.station for tr in st}
t1=np.arange(0,tr0.stats.npts/tr0.stats.sampling_rate,tr0.stats.delta)
fig,axis=plt.subplots(nrows=len(st))
#anim=[]
for ax,seed_id,tr in zip(axis,seed_ids,st):
ax.set_xlim([min(t1),max(t1)])
ax.set_ylim([min(tr.data),max(tr.data)])
ax.set_xlabel('time[S]')
ax.set_ylabel(f'{seed_id}')
animated_plot,=ax.plot([],[])
def update_data(frame):
animated_plot.set_data(t1[:frame],tr.data[:frame])
return animated_plot,
animation=FuncAnimation(fig=fig,
func=update_data,
frames=len(t1),
interval=10,
blit=True,
repeat_delay=1000,
)
plt.show()
how can I fix it to draw all trace at the same time ??
this what I got, its draw only one trace out of three in the stream data
本文标签:
版权声明:本文标题:multiple traces animation are not displaying, the code draws only one trace each running time? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303853a1932023.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论