Skip to content

Ipywidgets and interact #132

@Thomzoy

Description

@Thomzoy

Description

I'm using jupyter lite with xeus kernel. I'm using a simple script:

import numpy as np
import matplotlib.pyplot as plt
from ipywidgets import interact, FloatSlider
import ipywidgets as widgets

# Function to plot the sine wave
def plot_sine_wave(amplitude, frequency):
    x = np.linspace(0, 2 * np.pi, 100)
    y = amplitude * np.sin(frequency * x)
    plt.figure(figsize=(8, 4))
    plt.plot(x, y, label=f'Sine wave: amplitude={amplitude}, frequency={frequency}')
    plt.xlabel('x')
    plt.ylabel('y')
    plt.title('Interactive Sine Wave')
    plt.grid(True)
    plt.legend()
    plt.show()

amplitude_slider = FloatSlider(min=0.1, max=2.0, step=0.1, value=1.0, description='Amplitude:')
frequency_slider = FloatSlider(min=0.5, max=3.0, step=0.1, value=1.0, description='Frequency:')

interact(plot_sine_wave, amplitude=amplitude_slider, frequency=frequency_slider)

This works fine in jupyterlite's lab (the plot updates on slider change), but not on voici (no plot update).
Should it work as is ?

As a sidenote, using a simple IntSlider correctly updates the displayed number on the side of the widget, so some kind of interaction still works.

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions