Walking through matplotlib's animation example on my Mac OSX machine - http://matplotlib.org/examples/animation/simple_anim.html - I am getting this error:-
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 248, in _blit_clear
a.figure.canvas.restore_region(bg_cache[a])
AttributeError: 'FigureCanvasMac' object has no attribute 'restore_region'
Does anyone who has encountered this before know how to resolve this issue?
Looks like it's a known (and unresolved at this time of writing) issue - https://github.com/matplotlib/matplotlib/issues/531
Just set
blit=False
when animation.FuncAnimation() is called and it will work.
For instance (from double_pendulum_animated):
ani = animation.FuncAnimation(fig, animate, np.arange(1, len(y)), interval=25, blit=False, init_func=init)
You can avoid the problem by switching to a different backend:
import matplotlib
matplotlib.use('TkAgg')
As noted at https://mail.python.org/pipermail/pythonmac-sig/2012-September/023664.html use:
import matplotlib
matplotlib.use('TkAgg')
#just *before*
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
This has worked for me with Tkinter installed using the ActiveState Tkinter installation on OSX 10.11.6, Python 2.71 The basic animation example is still a little noisy until blt=False in the line_ani code here:
line_ani = animation.FuncAnimation(fig1, update_line, 25, fargs=(data, l),
interval=50, blit=False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With