Hello,
I try to update a figure by adding a new plot by setting the old one’s data source columns to be empty lists via callback.
Without using a legend, everything works. Otherwise the new plots resize weird. What is bokeh’s problem ?
Example:
from bokeh.plotting import figure, curdoc
from bokeh.layouts import column
from bokeh.models import Button, ColumnDataSource
i = 0
plot_sources = []
source = ColumnDataSource(data=dict(x=[1, 2], y=[2, 3]))
plot_sources.append(source)
p = figure(width=400, height=400)
p.circle("x", "y", source=source, legend="text")
def callback():
global i, plot_sources
i += 1
for source in plot_sources:
source.data = dict(x=[], y=[])
source = ColumnDataSource(data=dict(x=[1, 3], y=[i, 5]))
plot_sources.append(source)
p.circle("x", "y", source=source, legend="text %d" % i)
button = Button(label="Press Me")
button.on_click(callback)
curdoc().add_root(column(p, button))
Bokeh is a large project and like any large projects, it has its share of bugs. There have been several recent fixes for both layout issues some specialized server synchronization issues recently. I can't reproduce any problem with your code in the latest version off GitHub master, so perhaps you might have luck with the latest "dev build" which can be obtained with conda or pip:
Hello,
I try to update a figure by adding a new plot by setting the old one's data source columns to be empty lists via callback.
Without using a legend, everything works. Otherwise the new plots resize weird. What is bokeh's problem ?
Example:
from bokeh.plotting import figure, curdoc
from bokeh.layouts import column
from bokeh.models import Button, ColumnDataSource