开发者社区> 问答> 正文

如何使用描述和不同的fill_color数组在散景图上绘制散点图?

我试过以下,但颜色仍然是蓝色。

from bokeh.plotting import figure, show, output_file, ColumnDataSource

TOOLS="hover,crosshair,pan,wheel_zoom,zoom_in,zoom_out,box_zoom,undo,redo,reset,tap,save,box_select,poly_select,lasso_select,"

source = ColumnDataSource(data=dict(

    x=[1,2,3,4,5,6], 
    y=[2,2,4,5,6,7],
    desc=['type1', 'type1', 'type2','type2','type1','type1'],
    fill_color=['green','grey','grey','red','red','red'], 
    #fill_alpha=0.6, 
    #line_color=None
))

TOOLTIPS = [

    ("index", "$index"),
    ("(x,y)", "($x, $y)"),
    ("desc", "@desc"),
    ("fill_color", "@fill_color")]

p = figure(tools=TOOLS, plot_width=1000, tooltips=TOOLTIPS)
p.scatter(x='x',y='y', source=source)
output_file("color_scatter.html", title="color_scatter.py example")
show(p) # open a browser
QtZTU
如何在散景图上散布标签和独特颜色?

展开
收起
一码平川MACHEL 2019-01-16 16:41:24 2852 0
1 条回答
写回答
取消 提交回答
  • 您尚未告知scatter使用数据源中的颜色数据:

    p.scatter(x='x', y='y', fill_color='fill_color', source=source)

    2019-07-17 23:25:39
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载