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

本文标签: