Closed
Description
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