Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Pattarakorn Tussanapirom
2,467 PointsGraph not show
I have followed steps given in the video but graph is still not show up. My output is <function __main__.update (f, w=1, A=1, phi=0)>
2 Answers

Megan Amendola
Treehouse TeacherHi! Did you enable JavaScript to run in your notebook? Kenneth shows how to do this in the video starting at about 1:38. The code to run in your terminal is in the teacher's notes.

Sharina Jones
Data Analysis Techdegree Student 6,697 PointsInstalling Visualization Libraries
You can install the necessary packages using either pip
or conda
:
Using pip (inside or outside a notebook):
!pip install numpy bokeh panel
Or using conda:
conda install numpy bokeh -c conda-forge
conda install panel -c pyviz
Once installed, restart your Jupyter kernel to ensure the libraries are available.
Enabling Panel in JupyterLab
Panel works out of the box in JupyterLab version 3 and later (including version 4.3.4). You do not need to enable extensions manually. Just make sure you initialize it in your notebook with:
import panel as pn
pn.extension()
Creating an Interactive Plot with Panel and Bokeh
Paste the following code into a new notebook cell to create an interactive wave plot:
import numpy as np
import panel as pn
from bokeh.plotting import figure
from bokeh.io import output_notebook
pn.extension()
output_notebook()
# Create initial data
x = np.linspace(0, 2 * np.pi, 2000)
y = np.sin(x)
# Set up the plot
p = figure(title='Interactive Wave Plot', height=300, width=600, y_range=(-5, 5))
r = p.line(x, y, color='navy', line_width=3)
# Define the update function
def update(f="sin", w=1, A=1, phi=0):
func = {"sin": np.sin, "cos": np.cos, "tan": np.tan}[f]
r.data_source.data['y'] = A * func(w * x + phi)
# Create widgets
f_widget = pn.widgets.Select(name='Function', options=["sin", "cos", "tan"], value="sin")
w_widget = pn.widgets.IntSlider(name='Frequency (w)', start=0, end=100, value=1)
A_widget = pn.widgets.IntSlider(name='Amplitude (A)', start=1, end=5, value=1)
phi_widget = pn.widgets.FloatSlider(name='Phase (phi)', start=0, end=20, step=0.1, value=0)
# Bind widgets to function
pn.bind(update, f=f_widget, w=w_widget, A=A_widget, phi=phi_widget)
# Layout and display
layout = pn.Row(pn.Column(f_widget, w_widget, A_widget, phi_widget), p)
layout
This layout uses Panel
to create a live-updating graph of sine, cosine, and tangent waves. You can control the frequency, amplitude, and phase using sliders, and switch wave types using a dropdown menu.
Jessica Dobson
Data Analysis Techdegree Graduate 33,377 PointsJessica Dobson
Data Analysis Techdegree Graduate 33,377 PointsI have the same output as above, but running the code in the teacher's notes doesn't work because I'm in Jupyter 7 and it just keeps saying nbextenstion not found.