holoviews文档提到Bokeh工具栏可以隐藏或移动:http://holoviews.org/user_guide/Plotting_with_Bokeh.html bokeh文档显示了如何自动隐藏工具栏,使其仅在鼠标悬停时显示。
使用全息视图时是否可以自动隐藏工具栏,因为它不允许我传递诸如toolbar='autohide'
之类的选项
任何帮助都是最欢迎的。
fundYear.hvplot.bar(
x='year',
y='fundingReq',
rot=90,
).opts(
toolbar='left',
title="Funding Requested per Year",
yformatter='$%f',
)
答案 0 :(得分:1)
工具栏位置的可能设置为:
[“上”,“下”,“左”,“右”,“禁用”,无]
所以您不能像这样设置自动隐藏,但是...
1)您可以使用hooks设置自动隐藏。
使用挂钩,您可以在绘图之前自定义绘图。
def set_toolbar_autohide(plot, element):
bokeh_plot = plot.state
bokeh_plot.toolbar.autohide = True
your_plot.opts(hooks=[set_toolbar_autohide], backend='bokeh')
您还可以在常见问题解答中找到有关钩子的有用信息:
https://holoviews.org/FAQ.html
2)另一个解决方案是将Holoviews图转换为实际的散景图,然后将散景工具栏设置为自动隐藏:
快速解决方案基本上是:
my_bokeh_plot = hv.render(my_hv_plot, backend='bokeh')
my_bokeh_plot.toolbar.autohide = True
第二种解决方案的完整示例:
# import libraries
import numpy as np
import pandas as pd
import holoviews as hv
import hvplot.pandas
hv.extension('bokeh', logo=False)
from bokeh.plotting import show
# create sample dataframe
df = pd.DataFrame({
'col1': np.random.normal(size=30),
'col2': np.random.normal(size=30),
})
# create holoviews plot
my_hv_plot = df.hvplot.scatter(label='Scattering around', width=700)
# turn plot into bokeh plot
my_bokeh_plot = hv.render(my_hv_plot, backend='bokeh')
# set toolbar to autohide
my_bokeh_plot.toolbar.autohide = True
# show plot
show(my_bokeh_plot)