Matplotlib animating multiple lines and text

前端 未结 1 355
庸人自扰
庸人自扰 2020-12-30 12:42

Thanks for taking time to read my question, first time I have posted on SO so here goes...

I am plotting time series data in an animation using matplotlib.animation.

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-30 12:49

    def animate(i):
        timetext.set_text(i)
        x = numpy.array(range(1,npdata.shape[0]+1))
        for lnum,line in enumerate(lines):
            line.set_data(x,npdata[:,plotlays[lnum]-1,i])
        return lines, timetext # <- returns a tuple of form (list, artist)
    

    change this to

         return tuple(lines) + (timetext,)
    

    or something similar so that you return an iterable of artists from animate.

    0 讨论(0)
提交回复
热议问题