小编Mar*_*pus的帖子

在multi_line剧情的Bokeh hovertool

我是新手,我只是跳到了使用hovertool,因为这就是为什么我想首先使用散景.现在我正在绘制基因,我想要实现的是具有相同y坐标的多条线,当您将鼠标悬停在一条线上时,您将获得该基因的名称和位置.

我试图模仿这个例子,但由于某种原因,我甚至无法让它显示坐标.

我敢肯定,如果有人真正了解他们的方式看看这个代码,那么错误就会很明显,如果他们向我展示,我会非常感激.

from bokeh.plotting import figure, HBox, output_file, show, VBox, ColumnDataSource
from bokeh.models import Range1d, HoverTool
from collections import OrderedDict
import random

ys = [10 for x in range(len(levelsdf2[(name, 'Start')]))]
xscale = zip(levelsdf2[('Log', 'Start')], levelsdf2[('Log', 'Stop')])
yscale = zip(ys,ys)

TOOLS="pan,wheel_zoom,box_zoom,reset,hover"
output_file("scatter.html")
hover_tips = levelsdf2.index.values
colors = ["#%06x" % random.randint(0,0xFFFFFF) for c in range(len(xscale))]

source = ColumnDataSource(
    data=dict(
        x=xscale,
        y=yscale,
        gene=hover_tips,
        colors=colors,
    )
)


p1 = figure(plot_width=1750, plot_height=950,y_range=[0, 15],tools=TOOLS)
p1.multi_line(xscale[1:10],yscale[1:10], alpha=1, source=source,line_width=10, line_color=colors[1:10])

hover = p1.select(dict(type=HoverTool))
hover.tooltips = …
Run Code Online (Sandbox Code Playgroud)

python bokeh

5
推荐指数
1
解决办法
1786
查看次数

标签 统计

bokeh ×1

python ×1