Slicer with scatter plot isn't updated


Dateframe as above and I want to make an interactive graph with scatterplot and slider with year. The scatterplot wasn’t updated with the slicer. Could anyone help me with this? Thanks.


slider = Slider(title='my slider', start=1900, end=2019, step=1, value=1900)
source = ColumnDataSource({'x': a['land'], 'y': a['gross']})
p.circle('x', 'y', source=source)
def update_plot(attr, old, new):
    yr = slider.value
    new_data = {
        'x': a.loc[yr].land,
        'y': a.loc[yr].gross,
    }
    source.data = new_data

slider.on_change('value', update_plot)
layout = column(column(slider),p)
show(layout)


Hi @Ray,

Is this meant to be a standalone script, or a Bokeh server application?

Hi @carolyn, thanks for the instant reply.
I didn’t take the Bokeh server and just explored it in the Jupyter notebook.

@Ray,

If you’re working in a notebook, you’ll want a Javascript callback rather than a Python one. In fact, the notebook should have let you know with a big red error:

Try rewriting your callback in JS and let us know if you need assistance. Also, let us know if the error didn’t show for you-- that’d be good information for us to have!

And, if you do require real Python callbacks, you can embed a Bokeh server application in a notebook, but that has a particular structure to follow. See this example:

bokeh/notebook_embed.ipynb at branch-2.3 · bokeh/bokeh · GitHub

Thanks, @Bryan. It really works.