Hello,
I would like to be able to add glyph(s) dynamically to a plot based on user’s selection without bokeh server (Jupyter Notebook). My attempt doesn’t give me a desired result.
from bokeh.models.widgets import Select
from bokeh.plotting import figure, show
from bokeh.io import push_notebook, output_notebook
from bokeh.models import ColumnDataSource
from bokeh.layouts import widgetbox
from bokeh.models.widgets import Select
output_notebook()
source = ColumnDataSource(data=dict(x=[1,2,3], y=[5,3,8]))
p = figure(plot_width=600, plot_height=250)
p.circle(“x”, “y”, size=20, source=source)
def update(attr, old, new):
if new == “red”:
source.data[“z”] = [1, 1, 1]
p.circle(“x”, “z”, source=source, size=20)
push_notebook(handle=t)
select = Select(title=“Option:”, value=“blue”, options=[“blue”, “red”, “green”])
select.on_change(“value”, update)
show(column(widgetbox(select, width=50), p), notebook_handle=True)
``
Any comments/suggestions are highly appreciated.
Thank you for your time.