Iuli
Iuli

Reputation: 167

JupyterLab - Voila command is not creating the plot

I have the following code:

import numpy as np
import matplotlib.pyplot as plt
from ipywidgets import interactive, widgets
from IPython.display import display

def plot_sine_wave(frequency, amplitude):
    x = np.linspace(0,2*np.pi, 1000)
    y = amplitude * np.sin(frequency*x)
    plt.figure(figsize=(10,6))
    plt.plot(x,y)
    plt.show()



frequency_slider = widgets.FloatSlider(value=1.0, min=0.1, max=10.0, step=0.1, description='Frequency')
amplitude_slider = widgets.FloatSlider(value=1.0, min=0.1, max=10.0, step=0.1, description='Amplitude')
interactive_plot = interactive(plot_sine_wave, frequency=frequency_slider, amplitude=amplitude_slider)

display(interactive_plot)

and the output is:

enter image description here

but when I run voila myjupter.ipynb there is no output, only:

enter image description here

Is something else which I can try?

Upvotes: 0

Views: 46

Answers (0)

Related Questions