gpt4 book ai didi

scatter-plot - 如何使用 Bokeh 悬停工具显示自定义索引?

转载 作者:行者123 更新时间:2023-12-03 23:24:36 25 4
gpt4 key购买 nike

我正在使用 Bokeh 将 ~700 次模拟的结果与使用散点图的另一组结果进行对比。我想使用悬停工具通过分配标识模拟参数的自定义索引来定性地确定数据中的模式。

在下面的代码中,xy是来自 Pandas DataFrame 的列,它具有索引的模拟 ID。我已经能够使用 <DataFrameName>.index.values 将此索引分配给数组但我还没有找到任何关于如何为悬停工具分配索引的文档。

# Bokeh Plotting
h = 500
w = 500
default_tools = "pan, box_zoom, resize, wheel_zoom, save, reset"
custom_tools = ", hover"
fig = bp.figure(x_range=xr, y_range=yr, plot_width=w, plot_height=h, tools=default_tools+custom_tools)
fig.x(x, y, size=5, color="red", alpha=1)
bp.show(fig)

最佳答案

configuring the hover tool 的文档有一个如何做到这一点的例子对我有用。这是我使用的代码:

from bokeh.models import ColumnDataSource, HoverTool
cds = ColumnDataSource(
data=dict(
x=xdata,
y=ydata,
desc=sim
)
)
hover = HoverTool()
hover.tooltips = [
("Index", "$index"),
("(2z,1z)", "($x, $y)"),
("ID", "@desc")
]

关于scatter-plot - 如何使用 Bokeh 悬停工具显示自定义索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30521576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com