Skip to content

Artists not in Axes can not be animated with blit=True by FuncAnimation #11135

Closed as not planned
@bersbersbers

Description

@bersbersbers

Bug report

Bug summary

Text cannot be animated with blit=True. Code works fine with blit=False.

Code for reproduction

import matplotlib.animation
import matplotlib.pyplot

Animation = matplotlib.animation.FuncAnimation(
    matplotlib.pyplot.figure(),
    lambda x: (matplotlib.pyplot.suptitle(int(x)),),
    frames=1,
    blit=True)
matplotlib.pyplot.show(block=True)

Actual outcome
This error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\tkinter\__init__.py", line 1702, in __call__
    return self.func(*args)
  File "C:\Program Files\Python36\lib\tkinter\__init__.py", line 746, in callit
    func(*args)
  File "C:\Program Files\Python36\lib\site-packages\matplotlib\backends\_backend_tk.py", line 88, in _on_timer
    TimerBase._on_timer(self)
  File "C:\Program Files\Python36\lib\site-packages\matplotlib\backend_bases.py", line 1373, in _on_timer
    ret = func(*args, **kwargs)
  File "C:\Program Files\Python36\lib\site-packages\matplotlib\animation.py", line 1481, in _step
    still_going = Animation._step(self, *args)
  File "C:\Program Files\Python36\lib\site-packages\matplotlib\animation.py", line 1217, in _step
    self._draw_next_frame(framedata, self._blit)
  File "C:\Program Files\Python36\lib\site-packages\matplotlib\animation.py", line 1237, in _draw_next_frame
    self._post_draw(framedata, blit)
  File "C:\Program Files\Python36\lib\site-packages\matplotlib\animation.py", line 1260, in _post_draw
    self._blit_draw(self._drawn_artists, self._blit_cache)
  File "C:\Program Files\Python36\lib\site-packages\matplotlib\animation.py", line 1274, in _blit_draw
    bg_cache[a.axes] = a.figure.canvas.copy_from_bbox(a.axes.bbox)
AttributeError: 'NoneType' object has no attribute 'bbox'

Expected outcome

A plot with suptitle 0.

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: matplotlib==2.2.2
  • Matplotlib backend: TkAgg
  • Python version: 3.6.5
  • Jupyter version (if applicable): none
  • Other libraries:

Python from https://www.python.org/
Matplotlib using pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions