Matplotlib - Interactive Features
Identify the error in this interactive plot code snippet:
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider
fig, ax = plt.subplots()
x = range(5)
y = [i*2 for i in x]
line, = ax.plot(x, y)
slider_ax = plt.axes([0.25, 0.1, 0.65, 0.03])
slider = Slider(slider_ax, 'Multiplier', 1, 5, valinit=1)
def update(val):
line.set_ydata([i*val for i in x])
fig.canvas.draw_idle()
# Missing slider.on_changed(update)
plt.show()