Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animating a contour plot in matplotlib using FuncAnimation

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

like image 864
Eli S Avatar asked Dec 31 '25 12:12

Eli S


1 Answers

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!

like image 56
carla Avatar answered Jan 02 '26 05:01

carla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!