I would like to use a loop as a generator to create individual glyphs to generate a scatter plot. My x values are categorical values. I'm starting from the following simple example.
from bokeh.plotting import figure, show
xvals = ['one', 'two', 'three']
p = figure(x_range=xvals)
i=1
for value in xvals:
p.circle(x=value,y=i)
i+=1
show(p)
This results in Bokeh throwing the error:
Bokeh Error attempted to retrieve property array for nonexistent field 'one'
I'm guessing this can be sorted by using columndatasource and passing it as the source to the glyph rendering function. I've tried various ways to structure the data and pass it to the renderer, but without luck. The columndatasource object wants to be passed a dictionary with the format:
data = {'x_values': [1, 2, 3, 4, 5],
'y_values': [6, 7, 2, 3, 6]}
I am not able to call a complete list of y values before the generator as they will be computed during the loop in my real function. Is there any way around this? This is super easy to do with pyplot, but I need to use Bokeh for its interactive plots.
Thanks!