Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b81a08

Browse files
committed
Prevent exception when running animation on Agg backend.
Currently, running e.g. the strip_chart example using the agg backend (not a particularly interesting use case, but done in particular by the doc build) causes a "AttributeError: 'FuncAnimation' object has no attribute '_cache_frame_data'" exception. This is fixed by moving the setting of the `_cache_frame_data` attribute to before the `super().__init__` call. Also move the setting of `_init_func` next to the one of `_func`, which seems to be a logical grouping.
1 parent e9b8d3f commit 1b81a08

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

lib/matplotlib/animation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,7 @@ def __init__(self, fig, func, frames=None, init_func=None, fargs=None,
16131613
else:
16141614
self._args = ()
16151615
self._func = func
1616+
self._init_func = init_func
16161617

16171618
# Amount of framedata to keep around for saving movies. This is only
16181619
# used if we don't know how many frames there will be: in the case
@@ -1644,7 +1645,7 @@ def __init__(self, fig, func, frames=None, init_func=None, fargs=None,
16441645
# As a workaround, convert save_count to a native python int.
16451646
self.save_count = int(self.save_count)
16461647

1647-
self._init_func = init_func
1648+
self._cache_frame_data = cache_frame_data
16481649

16491650
# Needs to be initialized so the draw functions work without checking
16501651
self._save_seq = []
@@ -1655,8 +1656,6 @@ def __init__(self, fig, func, frames=None, init_func=None, fargs=None,
16551656
# for a single frame from init, which is not what we want.
16561657
self._save_seq = []
16571658

1658-
self._cache_frame_data = cache_frame_data
1659-
16601659
def new_frame_seq(self):
16611660
# Use the generating function to generate a new frame sequence
16621661
return self._iter_gen()

0 commit comments

Comments
 (0)