diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index 423a714d021a..93eed7b84b98 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -1113,8 +1113,8 @@ class FuncAnimation(TimedAnimation): results of drawing from the first item in the frames sequence will be used. This function will be called once before the first frame. - If blit=True, *func* and *init_func* should return an iterable of - drawables to clear. + If blit=True, *func* and *init_func* must return an iterable of + artists to be re-drawn. *kwargs* include *repeat*, *repeat_delay*, and *interval*: *interval* draws a new frame every *interval* milliseconds. @@ -1195,6 +1195,9 @@ def _init_draw(self): else: self._drawn_artists = self._init_func() if self._blit: + if self._drawn_artists is None: + raise RuntimeError('The init_func must return a ' + 'sequence of Artist objects.') for a in self._drawn_artists: a.set_animated(self._blit) self._save_seq = [] @@ -1211,5 +1214,8 @@ def _draw_frame(self, framedata): # func needs to return a sequence of any artists that were modified. self._drawn_artists = self._func(framedata, *self._args) if self._blit: + if self._drawn_artists is None: + raise RuntimeError('The animation function must return a ' + 'sequence of Artist objects.') for a in self._drawn_artists: a.set_animated(self._blit)