Animation and Interaction
75 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Animation and Interaction ## Matplotlib Animation ## Plotly Interactive Features [Join Discord](https://discord.gg/gE2m4Qrdqv) [Previous**Plotly**](/notes/04-degree-electives-bscs4001-data-viz-week06-06-plotly)[Next**Dashboards**](/notes/04-degree-electives-bscs4001-data-viz-week07-07-dashboards)

Animation and Interaction
Matplotlib Animation
pythonimport matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import numpy as np fig, ax = plt.subplots() x = np.linspace(0, 2*np.pi, 100) line, = ax.plot(x, np.sin(x)) def update(frame): line.set_ydata(np.sin(x + frame/10)) return line, ani = FuncAnimation(fig, update, frames=100, interval=50) plt.show()
Plotly Interactive Features
pythonimport plotly.graph_objects as go fig = go.Figure() fig.add_trace(go.Scatter(x=[1,2,3], y=[1,3,2], mode='lines+markers')) fig.update_layout( title="Interactive Plot", xaxis=dict(title="X"), yaxis=dict(title="Y"), hovermode='x' ) fig.show()