Skip to content

[Bug]: AttributeError: 'TimedAnimation' object has no attribute '_framedata' #30831

@J0hn3ch

Description

@J0hn3ch

Bug summary

Hi,

I try to use TimedAnimation class to manage a figure which should plot some sensor data sent in synchronized way, but an AttributeError occurs and I see that in the documentation there is no "_framedata" parameter to set.

Code for reproduction

# The code I try to run is this one

# Matplotlib config
fig, ax = plt.subplots()
ax.grid()
ax.relim() # recompute the ax.dataLim
ax.autoscale_view() # update ax.viewLim using the new dataLim
line, = ax.plot([], [], lw=2)

xdata, ydata = [0], [0]
del xdata[:]
del ydata[:]
line.set_data(xdata, ydata)

t = itertools.count(start=0)
plt.pause(3)

# The errors occurs after in the TimedAnimation
ani_t = animation.TimedAnimation(fig, interval=10, repeat=True, blit=True)

# This line will be not executed
plt.show(block=False)

Actual outcome

Traceback (most recent call last):
  File "file.py", line 337, in <module>
    ani_t = animation.TimedAnimation(fig, interval=10, repeat=True, blit=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.12/site-packages/matplotlib/animation.py", line 1440, in __init__
    super().__init__(fig, event_source=event_source, *args, **kwargs)
  File "venv/lib/python3.12/site-packages/matplotlib/animation.py", line 892, in __init__
    self.frame_seq = self.new_frame_seq()
                     ^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.12/site-packages/matplotlib/animation.py", line 1146, in new_frame_seq
    return iter(self._framedata)
                ^^^^^^^^^^^^^^^
AttributeError: 'TimedAnimation' object has no attribute '_framedata'
venv/lib/python3.12/site-packages/matplotlib/animation.py:908: UserWarning: Animation was deleted without rendering anything. This is most likely not intended. To prevent deletion, assign the Animation to a variable, e.g. `anim`, that exists until you output the Animation using `plt.show()` or `anim.save()`.

Expected outcome

I expect to plot log data each 10 milliseconds

Additional information

No response

Operating system

No response

Matplotlib Version

3.10.7

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions