You'll need to dive into bokeh for this. You can do this either with a hook, or rendering the bokeh object and working with it directly:
Hook approach:
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)
)
Rendering the bokeh object and working with it:
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)
Both methods produce this plot:
