Bokeh 或 Holoviews 中的条形图工具提示
Bar chart tooltip in Bokeh or Holoviews
我想在 Bokeh 或 Holoviews 的条形图中包含工具提示。但是,它没有让数据显示工具提示,而是给我 ???。我已经尝试过 Bokeh 和 Holoviews 并且遇到了同样的问题。我知道这是在两者中讨论了一段时间的问题,并且想知道最近的合并是否修复了它,如果是的话,处理它的最佳方法是什么。
下面是我的散景代码我的全息视图代码基本相同。
p=Bar(df, 'Metrics', title="ED Metrics", values='Median', plot_width=900, plot_height=900, tooltips = [("Cases Recorded", "@Cases"), ("Cases Less Than Target", "@Less"), ("Median", "@Median")])
Bar
是旧的、已弃用的 bokeh.charts
API 的一部分,此后已从核心 Bokeh 中完全删除。它仍然可以作为 bkcharts
包使用,但它 完全没有维护和支持 。此时不应将其用于任何新工作。
但是,最近的工作大大改进了对使用稳定的条形图和其他分类图的支持,支持 bokeh.plotting
API。 large new User's Guide Section purely dedicated to explaining and demonstrating many kind of bar charts, both simple and sophisticated. Moreover, now that bar plots are easy to make using standard bokeh.plotting
calls, the general guidance and documentation for hover tools 现在也适用。
您尚未向 运行 提供包含数据的完整最小示例,因此我无法针对您的用例提供具体建议。这是一个简单的条形图的完整示例,它使用 pandas 统计数据(类似于 Bar
会做的)和悬停工具,使用 "cars" 示例数据和 bokeh.plotting
API:
from bokeh.io import show, output_file
from bokeh.models import HoverTool
from bokeh.plotting import figure
from bokeh.sampledata.autompg import autompg as df
output_file("groupby.html")
df.cyl = df.cyl.astype(str)
group = df.groupby('cyl')
p = figure(plot_height=350, x_range=group, toolbar_location=None, tools="")
p.vbar(x='cyl', top='mpg_mean', width=0.9, source=group)
p.add_tools(HoverTool(tooltips=[("Avg MPG", "@mpg_mean")]))
show(p)
产生以下结果
我想在 Bokeh 或 Holoviews 的条形图中包含工具提示。但是,它没有让数据显示工具提示,而是给我 ???。我已经尝试过 Bokeh 和 Holoviews 并且遇到了同样的问题。我知道这是在两者中讨论了一段时间的问题,并且想知道最近的合并是否修复了它,如果是的话,处理它的最佳方法是什么。 下面是我的散景代码我的全息视图代码基本相同。
p=Bar(df, 'Metrics', title="ED Metrics", values='Median', plot_width=900, plot_height=900, tooltips = [("Cases Recorded", "@Cases"), ("Cases Less Than Target", "@Less"), ("Median", "@Median")])
Bar
是旧的、已弃用的 bokeh.charts
API 的一部分,此后已从核心 Bokeh 中完全删除。它仍然可以作为 bkcharts
包使用,但它 完全没有维护和支持 。此时不应将其用于任何新工作。
但是,最近的工作大大改进了对使用稳定的条形图和其他分类图的支持,支持 bokeh.plotting
API。 large new User's Guide Section purely dedicated to explaining and demonstrating many kind of bar charts, both simple and sophisticated. Moreover, now that bar plots are easy to make using standard bokeh.plotting
calls, the general guidance and documentation for hover tools 现在也适用。
您尚未向 运行 提供包含数据的完整最小示例,因此我无法针对您的用例提供具体建议。这是一个简单的条形图的完整示例,它使用 pandas 统计数据(类似于 Bar
会做的)和悬停工具,使用 "cars" 示例数据和 bokeh.plotting
API:
from bokeh.io import show, output_file
from bokeh.models import HoverTool
from bokeh.plotting import figure
from bokeh.sampledata.autompg import autompg as df
output_file("groupby.html")
df.cyl = df.cyl.astype(str)
group = df.groupby('cyl')
p = figure(plot_height=350, x_range=group, toolbar_location=None, tools="")
p.vbar(x='cyl', top='mpg_mean', width=0.9, source=group)
p.add_tools(HoverTool(tooltips=[("Avg MPG", "@mpg_mean")]))
show(p)
产生以下结果