python - 如何使用描述和不同的填充颜色数组在散景上绘制散点图?
问题描述
我尝试了以下方法,但颜色仍然是蓝色。
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
如何在散景散点图上同时拥有标签和独特的颜色?
解决方案
您没有告诉scatter
使用数据源中的颜色数据:
p.scatter(x='x', y='y', fill_color='fill_color', source=source)
推荐阅读
- mysql - 我正在尝试使用此查询创建一个 VIEW 但不起作用
- python - 从 div 标签中抓取网页正在返回随机产品的标题名称,而它应该返回第一个
- flutter - 在 setState 渲染后执行函数
- amazon-eks - 通过 aws cli - 我如何获得创建 eks 集群的实体的 arn?
- css - 防止内容增加 CSS 网格列的大小
- css - 如何水平对齐按钮和ul元素
- linux - 如何为 BASH 垃圾箱脚本添加选项?
- scala - 在 Akka 中创建演员的首选方式是什么?
- windows-10 - 不全屏播放幻灯片的窗口的图像查看器
- python - 字符串列表或单个字符串中的命名元组之间的区别?