My current code does not yield the expected result:
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
colors = cm.rainbow(np.linspace(0, 1, len(gt_x)))
for i in range(len(gt_x)):
ax.scatter(gt_x[i], gt_y[i], gt_z[i], s=50, marker='o', c=colors[i], label='gt')
ax.scatter(pred_x[i], pred_y[i], pred_z[i], s=50, marker='x', c=colors[i], label='predicted')
fig.canvas.draw()
data = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep="")
data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
imgs.append([plt.imshow(data, animated=True)])
clip = animation.ArtistAnimation(fig, imgs, interval=100, blit=False, repeat_delay=1000)
name = os.path.join("../data", "scatter_plot") + ".gif"
clip.save(name, writer='imagemagick')
I want to use the same logic, i.e. adding 3d points to my scatter plot iteratively, with a FuncAnimation
and offsets which seems to be the correct way to do what I want.
However, this involves using 3D offsets and ax update functions which I do not know how to use for this purpose since many functions seem to be private and thus not documented, e.g. ax._3doffsets()
.