Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Error at save animation with pillow #15678

Copy link
Copy link
Closed
@Zachary4biz

Description

@Zachary4biz
Issue body actions

Bug report

Bug summary

line 575 of animation.py use Image.frombytes to load a BytesIO, this will lead to an exception -- not enough image data.
seems we can't feed bytes of .png to frombytes from the first question-comment of this SO question

Code for reproduction

import numpy as np
from matplotlib import animation
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

emb = np.random.random_sample((1000,3))

fig = plt.figure("bug_report")
ax = Axes3D(fig)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_xlim3d(left=-1,right=1)
ax.set_ylim3d(bottom=-1,top=1)
ax.set_zlim3d(bottom=-1,top=1)

batch=50
def animate(i):
    emb_part = emb[i*batch:(i+1)*batch]
    ax.scatter(xs=emb_part[:, 0], ys=emb_part[:, 1], zs=emb_part[:, 2])
    return ax

ani = animation.FuncAnimation(fig=fig, func=animate, frames=len(emb)//batch + 1, interval=0.01*1000, blit=False, repeat=False)

ani.save("/Users/zac/Downloads/ani.gif", fps=30, writer='pillow')

Actual outcome

# ....
ValueError: not enough image data

During handling of the above exception, another exception occurred:
# ....

actually, if we use plt.show() before ani.save, this exception wont appear, but we will get only some last parts of the animation, example as this

Expected outcome

normally saved gif pic
example as this

Matplotlib version

  • Operating system: MacOSX
  • Matplotlib version: 3.0.3
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.7.3
  • Jupyter version (if applicable):
  • Other libraries: numpy

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.