celluloid
celluloid copied to clipboard
TypeError: zip argument #2 must support iteration
x = 3.5*np.ones(2)
samples = x
fig = plt.figure()
camera = Camera(fig)
plt.scatter(x[0], x[1], s=30, c='pink', edgecolor='red')
for i in range(200):
x[0] = np.random.normal(a*x[1], 1) # mu=ax[1], sigma=1
x[1] = np.random.normal(a*x[0], 1)
samples = np.append(samples, (x))
samples = samples.reshape((-1, x.shape[0]))
plt.scatter(samples[:i, 0], samples[:i, 1], s=10, c='pink', alpha=0.7, edgecolor='red')
t2 = plt.scatter(x[0], x[1], s=30, c='red', edgecolor='blue')
plt.legend(t2, [f'New Point: {i}'])
camera.snap()
animation = camera.animate(blit=False, interval=150)
animation.save('celluloid_minimal.gif', writer='pillow')
Legend Error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-158-32af401ce45e> in <module>()
15 t2 = plt.scatter(x[0], x[1], s=30, c='red', edgecolor='blue')
16 print(type(t2))
---> 17 plt.legend(t2, [f'New Point: {i}'])
18 # plt.legend()
19 camera.snap()
2 frames
/usr/local/lib/python3.6/dist-packages/matplotlib/pyplot.py in legend(*args, **kwargs)
2683 @docstring.copy(Axes.legend)
2684 def legend(*args, **kwargs):
-> 2685 return gca().legend(*args, **kwargs)
2686
2687
/usr/local/lib/python3.6/dist-packages/matplotlib/axes/_axes.py in legend(self, *args, **kwargs)
404 if len(extra_args):
405 raise TypeError('legend only accepts two non-keyword arguments')
--> 406 self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
407 self.legend_._remove_method = self._remove_legend
408 return self.legend_
/usr/local/lib/python3.6/dist-packages/matplotlib/legend.py in __init__(self, parent, handles, labels, loc, numpoints, markerscale, markerfirst, scatterpoints, scatteryoffsets, prop, fontsize, borderpad, labelspacing, handlelength, handleheight, handletextpad, borderaxespad, columnspacing, ncol, mode, fancybox, shadow, title, title_fontsize, framealpha, edgecolor, facecolor, bbox_to_anchor, bbox_transform, frameon, handler_map)
457 # trim handles and labels if illegal label...
458 _lab, _hand = [], []
--> 459 for label, handle in zip(labels, handles):
460 if isinstance(label, str) and label.startswith('_'):
461 cbook._warn_external('The handle {!r} has a label of {!r} '
Samples have not been updated in your code and why the writer is 'pillow' but not 'imagemagick'?