简体   繁体   English

更改散景十字准线工具的颜色

[英]Change color of Bokeh CrosshairTool

Is there a way to change the color for CrosshairTool in Bokeh?有没有办法在 Bokeh 中更改 CrosshairTool 的颜色?

From another related question I borrowed this example code:另一个相关问题中,我借用了这个示例代码:

import numpy as np
from bokeh.plotting import figure, show
from bokeh.layouts import gridplot
from bokeh.models import CrosshairTool

plots = [figure() for i in range(6)]
[plot.line(np.arange(10), np.random.random(10)) for plot in plots]

linked_crosshair = CrosshairTool(dimensions="both")

for plot in plots:
    plot.add_tools(linked_crosshair)

show(gridplot(children=[plot for plot in plots], ncols=3))

As per the documentation: http://docs.bokeh.org/en/latest/docs/reference/models/tools.html#crosshairtool根据文档: http ://docs.bokeh.org/en/latest/docs/reference/models/tools.html#crosshairtool

Set the public attributes line_color and line_alpha to modify the stroke path.设置公共属性line_colorline_alpha来修改笔触路径。

line_alpha = 1.0 line_alpha = 1.0

An alpha value to use to stroke paths with.用于描边路径的 alpha 值。

Acceptable values are floating-point numbers between 0 and 1 (0 being transparent and 1 being opaque).可接受的值是介于 0 和 1 之间的浮点数(0 表示透明,1 表示不透明)。

line_color = 'black' line_color = '黑色'
A color to use to stroke paths with.用于描边路径的颜色。

Acceptable values are:可接受的值为:

  • any of the named CSS colors, eg 'green', 'indigo'任何命名的 CSS 颜色,例如 'green'、'indigo'
  • RGB(A) hex strings, eg, '#FF0000', '#44444444' RGB(A) 十六进制字符串,例如,'#FF0000'、'#44444444'
  • CSS4 color strings, eg, 'rgba(255, 0, 127, 0.6)', 'rgb(0 127 0 /1.0)', or 'hsl(60deg 100% 50% / 1.0)' CSS4 颜色字符串,例如 'rgba(255, 0, 127, 0.6)'、'rgb(0 127 0 /1.0)' 或 'hsl(60deg 100% 50% / 1.0)'
  • a 3-tuple of integers (r, g, b) between 0 and 255 0 到 255 之间的整数 (r, g, b) 的 3 元组
  • a 4-tuple of (r, g, b, a) where r, g, b are integers between 0 and 255, and a is between 0 and 1 (r, g, b, a) 的 4 元组,其中 r, g, b 是 0 到 255 之间的整数,a 是 0 到 1 之间的整数
  • a 32-bit unsigned integer using the 0xRRGGBBAA byte order pattern使用 0xRRGGBBAA 字节顺序模式的 32 位无符号整数

You can set line_width to set the stroke width in pixels.您可以设置line_width以设置笔画宽度(以像素为单位)。 (Default 1) (默认 1)

The documentation isn't explicit, but it should also be possible to set these properties as a theme using the apply_theme(property_values: Dict[str, Any]) method文档不明确,但也应该可以使用apply_theme(property_values: Dict[str, Any])方法将这些属性设置为主题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM