# Trouble updating plot through callback

**URL:** <https://discourse.bokeh.org/t/trouble-updating-plot-through-callback/2618>\
**Category:** Community Support\
**Created:** [November 19, 2017, 5:11pm UTC](https://discourse.bokeh.org/t/trouble-updating-plot-through-callback/2618 "2017-11-19T17:11:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![emihau.bks](https://discourse.bokeh.org/letter_avatar_proxy/v4/letter/e/8edcca/32.png) [@emihau.bks](https://discourse.bokeh.org/u/emihau.bks)\
**Post date:** [November 19, 2017, 5:11pm UTC](https://discourse.bokeh.org/t/trouble-updating-plot-through-callback/2618/1 "2017-11-19T17:11:10Z")

</div>

Hi, I’m fairly new to bokeh and I can see there are a lot of posts on this topic, but I’ve been googling this all weekend, without finding a solution, so I’ll try here:

I have some trouble implementing a RangeSlider and Select widget. They show up in the plot with their initial values, but nothing happens to the plot when click on them.

I can only assume this has to do with my callback methods, but I can’t see how they differ from the callback function in e.g. [bokeh/main.py at branch-3.0 · bokeh/bokeh · GitHub](https://github.com/bokeh/bokeh/blob/master/examples/app/gapminder/main.py) (the slider\_update() - method). Here’s my bokeh script:

import pandas as pd

from [bokeh.io](http://bokeh.io) import curdoc

from bokeh.models import ColumnDataSource, Slider, Select

from bokeh.plotting import figure

from bokeh.models.widgets import RangeSlider

from bokeh.layouts import column, row

df = pd.read\_csv(“temperature.csv”, header=0)

source = ColumnDataSource(df)

months = df.columns.values.tolist()

plot = figure(plot\_width=1000, plot\_height=600)

plot.line(x=“Year”, y=“January”, source=source)

menu = Select(options=months, value=“June”, title=“Month”)

start, end = df[“Year”].iloc[0], df[“Year”].iloc[-1]

slider = RangeSlider(start=start, end=end, value=(start, end), step=1, title=“Year”)

def select\_callback(attr, old, new):

```
source.data = df[menu.value]

```

menu.on\_change(‘value’, select\_callback)

def slider\_callback(attr, old, new):

```
source.data = df.loc[slider.value[0] : slider.value[1], :]

```

slider.on\_change(‘value’, slider\_callback)

layout = column(plot, row(menu, slider))

curdoc().add\_root(layout)

``

I am trying to show this plot in the browser using Flask, with the app:

from flask import Flask, render\_template

from bokeh.embed import autoload\_server

app = Flask( **name** )

@app.route("/")

def index():

script = autoload\_server(None, url=“[http://localhost:5006/plot\_script](http://localhost:5006/plot_script)”)

return render\_template(“temp.html”)

if **name** ==“ **main** ”:

app.run(port=5000, debug=True)

``

Both the Flask app and running with simply bokeh serve --show plot\_script.py yield the same unresponsive graph.

The csv file has no issues, but there might be something wrong with the html template. Does anyone have any idea as to how to generate a template from the plot\_script.py program? (See attchments)

[temperature.csv](https://discourse-uploads.bokeh.org/original/1X/fb1718ebe156561713e5ff4bd67b058f8e548b43.csv) (24.7 KB)

[temp.html](https://discourse-uploads.bokeh.org/original/1X/2e117a0aedc8d587aa47448ec456f60169c163d8.html) (36.5 KB)

---

<div class="post-metadata">

**Author:** ![emihau.bks](https://discourse.bokeh.org/letter_avatar_proxy/v4/letter/e/8edcca/32.png) [@emihau.bks](https://discourse.bokeh.org/u/emihau.bks)\
**Post date:** [November 19, 2017, 7:43pm UTC](https://discourse.bokeh.org/t/trouble-updating-plot-through-callback/2618/2 "2017-11-19T19:43:37Z")

</div>

EDIT:

Please disregard everything about Flask, that code is completely wrong, sorry!

Assume I’m running simply:

> > bokeh serve --show plot\_script.py

The same problems with the plot not updating still holds. Any ideas?

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads.bokeh.org/original/2X/1/14eb24f9e10e4e9b78e3f10f66c04ffa96446e5a.svg) [@system](https://discourse.bokeh.org/u/system)\
**Post date:** [July 21, 2021, 9:13pm UTC](https://discourse.bokeh.org/t/trouble-updating-plot-through-callback/2618/3 "2021-07-21T21:13:30Z")

</div>


