报错内容: raise RuntimeError(_GLYPH_SOURCE_MSG % nice_join(incompatible_literal_spec_values, conjuction="and"))
RuntimeError:
Expected fill_color to reference fields in the supplied data source.
When a 'source' argument is passed to a glyph method, values that are sequences
(like lists or arrays) must come from references to data columns in the source.
For instance, as an example:
source = ColumnDataSource(data=dict(x=a_list, y=an_array))
p.circle(x='x', y='y', source=source, ...) # pass column names and a source
Alternatively, all data sequences may be provided as literals as long as a
source is not provided:
p.circle(x=a_list, y=an_array, ...) # pass actual sequences and no source
涉及到的代码部分
#cannot use seaborn palette for bokeh
palette =['red','green','blue','yellow']
colors =[]
for i in range(len(sublist)):
for j in range(lenlist[i+1]-lenlist[i]):
colors.append(palette[i])
#plot with boken
output_file(filename)
source = ColumnDataSource(
data=dict(x=tsne[:,0],y=tsne[:,1],
cuisine = df_sub['cuisine'],
recipe = df_sub['recipeName']))
hover = HoverTool(tooltips=[
("cuisine", "@cuisine"),
("recipe", "@recipe")])
p = figure(plot_width=1000, plot_height=1000, tools=[hover],
title="flavor clustering")
p.circle('x', 'y', size=10, source=source,fill_color=colors)
show(p)
请问怎么纠正这个错误啊?