Hi I got stuck in one of my ML-related projects. I wanted to use interactive diagrams, but my plots are not interactive. (I tried to run it in both Google Colab and Jupyter notebook(browser) )

**this is my code:**

import numpy as np

import matplotlib.pyplot as plt

from matplotlib.widgets import Slider

# Sample data

X = np.arange(10)

y = 2 * X + np.random.normal(0, 1, 10)

# Linear regression model

def linear_regression_line(slope, intercept):

return slope * X + intercept

# Initial plot

fig, ax = plt.subplots()

plt.subplots_adjust(bottom=0.25)

ax.scatter(X, y, label=‘Data points’)

[line] = ax.plot(X, linear_regression_line(2, 0), ‘r-’, label=‘Regression line’)

ax.set_xlabel(‘X’)

ax.set_ylabel(‘y’)

ax.legend()

# Slider for slope and intercept

ax_slope = plt.axes([0.25, 0.1, 0.65, 0.03])

ax_intercept = plt.axes([0.25, 0.15, 0.65, 0.03])

slope_slider = Slider(ax_slope, ‘Slope’, 0.0, 4.0, valinit=2.0)

intercept_slider = Slider(ax_intercept, ‘Intercept’, -10.0, 10.0, valinit=0.0)

# Update function for the slider

def update(val):

line.set_ydata(linear_regression_line(slope_slider.val, intercept_slider.val))

fig.canvas.draw_idle()

slope_slider.on_changed(update)

intercept_slider.on_changed(update)

plt.show()

this plot is generated, but the sliders should’ve been interactive. Can you please help me with this?