为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

婷婷同学_ 2021-10-12 10:27:49
我尝试了以下方法,但颜色仍然是蓝色。from bokeh.plotting import figure, show, output_file, ColumnDataSourceTOOLS="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如何在散景散点上同时拥有标签和独特的颜色?
查看完整描述

1 回答

?
白猪掌柜的

TA贡献1893条经验 获得超10个赞

您没有告诉scatter使用数据源中的颜色数据:

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


查看完整回答
反对 回复 2021-10-12
  • 1 回答
  • 0 关注
  • 183 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号