I am trying to plot several graphs in Bokeh, but I get the following error:
RuntimeError: Models must be owned by only a single document, Selection(id='1057', ...) is already in a doc.
I know that this is caused when trying to use the same objects in multiple docs, but I don't understand where I am doing that. Here is the entire (simplified) code.
I'm using Bokeh 1.4.0.
from bokeh.plotting import figure, show
from bokeh.layouts import row, gridplot
from bokeh.models import ColumnDataSource
from bokeh.io import output_file
import pandas as pd
feature_groups = [['ciao'],['bye']]
df = pd.DataFrame.from_dict({'x':[0,1,2,3,4], 'y':[2,3,4,5,6]})
x_test = [0,1,2,3,4]
y_test = [2,3,4,5,6]
source = ColumnDataSource(df)
for features_columns in feature_groups:
output_file('features_labels' + features_columns[0] +'.html')
p = []
for k,f in enumerate(features_columns):
p_k = figure(title=f)
p_k.circle(x=f, y='ki', line_width=2, source=source,fill_alpha=0.5,line_alpha=0.5)
p_k.circle_cross( x=x_test, y=y_test, color='red',fill_alpha=0.5,line_alpha=0.5)
p_k.circle_cross( x = x_test, y = y_test, color='green',fill_alpha=0.5,line_alpha=0.5)
p_k.xaxis.axis_label = f
p_k.yaxis.axis_label = 'ki'
p.append(p_k)
grid = gridplot(p, ncols=2)
show(grid)
thank you in advance