
I am attempting to have a variable number of figures depened on the number of columns in a dataframe. The attached code works but still plots and functions fine. What am I doing incorrectly to throw an error?
Thanks for any help
Error:
ERROR:bokeh.core.validation.check:E-1027 (REPEATED_LAYOUT_CHILD): The same model can’t be used multiple times in a layout: Column(id=‘p1145’
Code:
import pandas as pd
from bokeh.palettes import Category20_20, inferno
from bokeh.layouts import layout, column, row
import datetime
from datetime import datetime, timedelta, date
import bokeh.plotting
import bokeh.layouts
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource, Legend
data = [{'a': 1, 'b': 2, 'c': 3},{'a': 10, 'b': 20, 'c': 30},{'a': 20, 'b': 30, 'c': 50},{'a': 30 ,'b': 40, 'c': 90}]
dfM = pd.DataFrame(data)
plots = []
source = dfM
CL =1;colors = iter(Category20_20)
p = figure(title='test',sizing_mode="stretch_width",toolbar_location='right')
PlotStep = 1;LineLimiter = 2;count = 0
for col in dfM:
if count < LineLimiter:
if col != 'TimeStep':
for r in range(LineLimiter+1):
if CL== 20: # resets colors
colors = iter(Category20_20)
CL=1
p.line(x = dfM['a'], y = dfM[col], color=next(colors),legend_label=col)
CL=CL+1
plots.append(p)
p.xaxis.ticker.desired_num_ticks = 20
p.legend.click_policy="hide"
count = count +1
if count >= LineLimiter:
count = 0
PlotStep = PlotStep +1
p = figure(title='test',
sizing_mode="stretch_width",
toolbar_location='right',
)
if PlotStep >1:
LayOutR = column(*plots,sizing_mode="stretch_width")
else:
LayOutR = column(plots,sizing_mode="stretch_width")
p.xaxis.axis_label = 'My X-axis'
p.yaxis.axis_label = 'My Y-axis'
p.legend.click_policy="hide"
p.legend.location = 'right'
p.xaxis.ticker.desired_num_ticks = 20
show(LayOutR,sizing_mode="stretch_width")

