<jupyter_start><jupyter_text>Matplotlib 3d animation exampleFrom https://pythonmatplotlibtips.blogspot.com/2017/12/draw-3d-line-animation-using-python-matplotlib-funcanimation.html<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as p3
import matplotlib.animation as animation

from IPython.display import HTML
def update_lines(num, dataLines, lines):
    for line, data in zip(lines, dataLines):
        # NOTE: there is no .set_data() for 3 dim data...
        line.set_data(data[0:2, :num])
        line.set_3d_properties(data[2, :num])
        line.set_marker("o")
    return lines

# Attaching 3D axis to the figure
fig = plt.figure(figsize=(8, 5))
ax = p3.Axes3D(fig)

# Lines to plot in 3D
t = np.linspace(-2*np.pi,2*np.pi,50)
x1, y1, z1 = np.cos(t), np.sin(t), t/t.max()
x2, y2, z2 = t/t.max(), np.cos(t), np.sin(t)
data = np.array([[x1,y1,z1],[x2,y2,z2]])

# NOTE: Can't pass empty arrays into 3d version of plot()
lines = [ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1])[0] for dat in data]

ax.set_xlim(-1.1,1.1)
ax.set_ylim(-1.1,1.1)
ax.set_zlim(-1.1,1.1)
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
plt.rcParams['animation.html'] = 'html5'

line_ani = animation.FuncAnimation(fig, update_lines, 50, fargs=(data, lines),
                                   interval=100, blit=True, repeat=True)

plt.close()
line_ani
line_ani.save('line_animation_3d_funcanimation.gif', writer='imagemagick',fps=1000/100)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1619110816191108, 'fraction_numerical': 0.0497677504976775, 'mean_word_length': 4.309859154929577, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '429399', 'license': 'MIT', 'n_tokens_mistral': 650, 'n_tokens_neox': 618, 'n_words': 124, 'path': '2018-2019/assignment 2 (FNN & Optimization)/Animation_playground.ipynb', 'repo_name': 'Tudor67/Neural-Networks-Assignments', 'size': '1507'}