散景射线字形不显示工具提示
Bokeh Ray glyphs not displaying tooltips
我无法在 Bokeh(v2.2.3 和 Python 3.8.6)中使用 HoverTool 使用 Ray 字形。工具提示不会显示。
import numpy as np
from bokeh.io import output_notebook, show
from bokeh.models import ColumnDataSource, HoverTool, Range1d
from bokeh.plotting import figure
output_notebook()
N = 9
x0 = np.zeros(N)
y0 = np.ones(N)
x = np.linspace(-2, 2, N)
y = x**2
z = x + 1j * y
source = ColumnDataSource(dict(x=x0, y=y0, length=np.absolute(z), angle=np.angle(z)))
fig = figure(title='', plot_width=300, plot_height=300)
fig.ray(x='x', y='y', length='length', angle='angle', source=source, line_width=2)
tooltips = [('length', '@length'), ('angle', '@angle')]
fig.add_tools(HoverTool(tooltips=tooltips))
fig.x_range = Range1d(-2, 2)
fig.y_range = Range1d(0, 4)
show(fig)
射线字形目前不支持任何 hit-testing(即它们不能与悬停工具一起使用)。
https://github.com/bokeh/bokeh/wiki/Glyph-Hit-Testing-Census
您的最佳选择是 segment
或 multi_line
。
我无法在 Bokeh(v2.2.3 和 Python 3.8.6)中使用 HoverTool 使用 Ray 字形。工具提示不会显示。
import numpy as np
from bokeh.io import output_notebook, show
from bokeh.models import ColumnDataSource, HoverTool, Range1d
from bokeh.plotting import figure
output_notebook()
N = 9
x0 = np.zeros(N)
y0 = np.ones(N)
x = np.linspace(-2, 2, N)
y = x**2
z = x + 1j * y
source = ColumnDataSource(dict(x=x0, y=y0, length=np.absolute(z), angle=np.angle(z)))
fig = figure(title='', plot_width=300, plot_height=300)
fig.ray(x='x', y='y', length='length', angle='angle', source=source, line_width=2)
tooltips = [('length', '@length'), ('angle', '@angle')]
fig.add_tools(HoverTool(tooltips=tooltips))
fig.x_range = Range1d(-2, 2)
fig.y_range = Range1d(0, 4)
show(fig)
射线字形目前不支持任何 hit-testing(即它们不能与悬停工具一起使用)。
https://github.com/bokeh/bokeh/wiki/Glyph-Hit-Testing-Census
您的最佳选择是 segment
或 multi_line
。