如何在不删除全息视图中的轴标签的情况下单独 hide/remove 轴

How to hide/remove the axis alone without removing the axis labels in holoviews

当我加入... .opts(title="Graph",ylabel="Count",width=400,axiswise=True,xaxis='bare') xasis='bare'xaxis=none 它使整个轴连同 holoviews 中的标签一起消失。如何在显示 axis 标签时仅删除轴? 这里的标签是 ylabel 因为轴是倒转的。 ylabelxaxis

设置标签

参考 示例图表代码

还有一种方法可以在全息视图中为 side-by-side 地块指定主标题,而不是单独的地块标题。

为此,您需要深入研究散景。您可以使用钩子来执行此操作,也可以渲染散景对象并直接使用它:

挂钩方法:

import holoviews as hv
hv.extension("bokeh")

def hook(plot, element):
    plot.state.xaxis.major_tick_line_color = None        # turn off x-axis major ticks
    plot.state.xaxis.minor_tick_line_color = None        # turn off x-axis minor ticks
    plot.state.xaxis.major_label_text_font_size = '0pt'  # turn off x-axis tick labels


df = pd.DataFrame({
    "set": list("ABABCCAD"),
    "flag": list("YYNNNYNY"),
    "id": list("DEFGHIJK"),
})

df = df.groupby(["set", "flag"])["id"].count().reset_index()
count_bars = hv.Bars(df, kdims=["set","flag"], vdims="id")

plot = (count_bars
        .opts(hooks=[hook], title="IDs",invert_axes=True, width=500, padding=2)
        .redim.values(flag=["Y", "N"]) # Inverting the axes flips this order. This produces N, Y vertically
        .sort("set", reverse=True)
       )

渲染散景对象并使用它:

from bokeh.io import show
import holoviews as hv
hv.extension("bokeh")
    
df = pd.DataFrame({
    "set": list("ABABCCAD"),
    "flag": list("YYNNNYNY"),
    "id": list("DEFGHIJK"),
})

df = df.groupby(["set", "flag"])["id"].count().reset_index()
count_bars = hv.Bars(df, kdims=["set","flag"], vdims="id")

plot = (count_bars
        .opts(title="IDs",invert_axes=True, width=500, padding=2)
        .redim.values(flag=["Y", "N"]) # Inverting the axes flips this order. This produces N, Y vertically
        .sort("set", reverse=True)
       )

bokeh_figure = hv.render(plot)
bokeh_figure.xaxis.major_tick_line_color = None        # turn off x-axis major ticks
bokeh_figure.xaxis.minor_tick_line_color = None        # turn off x-axis minor ticks
bokeh_figure.xaxis.major_label_text_font_size = '0pt'  # turn off x-axis tick labels

show(bokeh_figure)

这两种方法都会生成此图: