I'm fairly new to Bokeh so still probably missing something with it, but I keep running into issues when trying to use Span on multiple plots if I'm generating the plots in a loop. Here's what I'm trying:
titleString = 'Test Plot'
plotVals = [1, 2]
upperLimit = Span(location=6, dimension='width', line_color='red', line_dash='dashed', line_width=1)
lowerLimit = Span(location=-6, dimension='width', line_color='red', line_dash='dashed', line_width=1)
xVals = [0,1,2,3,4]
yVals = [2,4,3,4,2]
for t in enumerate(plotVals):
print(t[1])
imgTitle = 'Span Test ' + str(t[0])
p = figure(title=imgTitle, plot_width=800, plot_height=450, y_range=(-8, 8), x_range=(-4,8))
p.add_layout(upperLimit)
p.add_layout(lowerLimit)
p.circle(xVals,yVals, size=5)
show(p)
reset_output()
The first graph comes out as expected, but the second fails with the following message:
ValueError: object to be added already has 'plot' attribute set
I assume I'm doing something stupid. Can someone point me in the right direction?