☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Sldier it not connecting to plot

Community Supportserver
ritesh.r.kumar
ritesh.r.kumar

Please help make this code work:
‘’’

Import Libraries

from bokeh.io import show
from bokeh.layouts import row
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource, Slider
import numpy as np

Define the Inputs

x = np.array([‘Jan-2019’, ‘Feb-2019’, ‘Mar-2019’, ‘Apr-2019’, ‘May-2019’, ‘Jun-2019’, ‘Jul-2019’, ‘Aug-2019’, ‘Sep-2019’, ‘Oct-2019’, ‘Nov-2019’, ‘Dec-2019’, ‘Jan-2020’, ‘Feb-2020’, ‘Mar-2020’, ‘Apr-2020’, ‘May-2020’, ‘Jun-2020’, ‘Jul-2020’])
y = np.array([20.1, 20.7, 21.9, 18.7, 19.7, 19.1, 20.0, 18.7, 19.3, 19.3, 19.2, 18.2, 18.5, 21.1, 25.0, 24.3, 23.7, 19.9, 19.7])
source = ColumnDataSource(data=dict(x=x, y=y))

Setup Plot

p = figure(title=‘Scores’, plot_height=300, plot_width=900)
p.line(x, y, color=‘#2222aa’, line_width=3)

Set up Slider

slider = Slider(title=“Trend for Months”, value=12, start=3, end=19, step=1)

Define Callback

def callback(attr, old, new):
print(N)
N = slider.value
y = y+N
source.data = dict(x=x, y=y)

Show the plot

slider.on_change(‘value’, callback)
layout = row(slider, p)
show(layout)

‘’’

⌁   Link to post
p-himik
p-himik

First of all, please format your code using the editor tools or ``` around the code.

As to your error - you should see an error in Python console. You’re doing y - N where y is a Python list, which doesn’t support the subtraction operation.

⌁   Link to post
ritesh.r.kumar
ritesh.r.kumar

Thank you for the prompt response. I have fixed the error that you pointed out. However, it still does not work. Doesn’t look like it is going into callback, becuase it is not printing N. Please take another look at it.

⌁   Link to post
_jm
_jm

@ritesh.r.kumar

The print statement is in a callback. If your plot and widget are not rendering, there’s not a mechanism in your example to affect a change that triggers the callback.

As noted by @p-himik, you need to change the code to use curdoc() and add_root() to render the models per the server documentation.

You’ll need to repost your updated code for additional help with the problem, and take care to properly format it in the issue so that it can be cut-and-pasted into a file for more efficient help.

⌁   Link to post

End of archived discussion · Replies are disabled