Animating a contour plot in matplotlib using FuncAnimation

旧时模样 提交于 2019-12-01 05:59:22

问题


I am trying to create an animation in matplotlib that updates three artists, including imshow, contour and text. Using FuncAnimation I am able to update the text and the image components, but have not been able to update the contour. Specifically, I tried this as my callback:

def updatefig(*args):
    text_component.set_text(newText())
    image_component.set_array(newArrayData())
    contour_component.set_array(newArrayData())
    return [text_component,image_component,contour_component]

This code doesn't raise an exception but neither does it update the contour lines. I wonder if this is just a matter my not knowing the right setter method of if there is more to it. Can anyone tell me if this is possible?

Thanks, Eli


回答1:


I didn´t full understand your code (also because it is not complete) and I would like rather to comment your question than answering it... (but I don't have enough reputation to be able to do it!)

Anyway... I think the problem might be related with the contour itself, which returns not an Artist, but a QuadContourSet instance! Do you think this might be the problem? I had something similar with the ArtistAnimation...

If this is the point, you have to "punch the QuadContourSet until it behaves like an Artist"... I could solve my problem with all the information in the link!

Good luck!



来源:https://stackoverflow.com/questions/9337188/animating-a-contour-plot-in-matplotlib-using-funcanimation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!