0

I want to turn a series of matplotlib figures into an animation. However, whatever I do, I always receive error. I use Enthought Canopy 1.6.2 and Python 2.7.13 on Windows 10.

I have tried using videofig package. While it was good, I could not manage to save the mp4 file. Also, I believe using the source directly, i.e., matplotlib animation package would be more versatile for future uses. I checked a few answers, including 1, 2 and 3, yet none of them solved my problem.

The function I call is structured as follows.

def some_plotter(self, path, start_value, image_array)
    some_unrelated_fig_functions()
    im=plt.savefig(path, animated=True)
    image_array.append([im])
    plt.close("all")

The main code is as follows:

import matplotlib.animation as animation
image_array=[]
while(something):
    some_obj.some_plotter(path, start_value, image_array)
fig = plt.figure()
ani = animation.ArtistAnimation(fig, image_array, interval=50, blit=True, repeat_delay=1000)

I receive the following error:

Traceback (most recent call last): File "C:\Users\kocac\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\matplotlib\cbook__init__.py", line 387, in process proxy(*args, **kwargs) File "C:\Users\kocac\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\matplotlib\cbook__init__.py", line 227, in call return mtd(*args, **kwargs) File "C:\Users\kocac\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\matplotlib\animation.py", line 1026, in _start self._init_draw() File "C:\Users\kocac\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\matplotlib\animation.py", line 1557, in _init_draw artist.set_visible(False) AttributeError: 'NoneType' object has no attribute 'set_visible'

I had more similar lines to this, yet updating Matplotlib, following the suggestion at 3 reduced the error lines to 4. Yet I cannot proceed any longer. Note that saved images are perfectly fine so I am probably not doing anything wrong in the image creation.

How can I get rid of these errors? Where am I going wrong?

2
  • 1
    I'm fairly sure you cannot use plt.close("all") in the middle of your animation, but one cannot help you unless you provide a Minimal, Complete, and Verifiable example, that is some code that we could copy/paste and run for ourselves Commented Aug 2, 2019 at 7:45
  • 1
    plt.savefig does not return anything useful, which can be animated. So if you print out image_array you should see a list of None. I would suggest to stick to the solutions you linked to. Commented Aug 2, 2019 at 11:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.