我无法在Bokeh(带有Python 3.8.6的v2.2.3)中使用Ray字形来与HoverTool一起使用。工具提示不会显示。
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)
射线字形当前不支持任何命中测试(即,它们不能与悬停工具一起使用)。
https://github.com/bokeh/bokeh/wiki/Glyph-Hit-Testing-Census
最好的选择是segment
或multi_line
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句