Grouped barchart: add legend and remove xticks

Basically I was trying to solve this stackoverflow question on grouped barcharts.
The goal is to add a legend to a grouped barchart and remove xticks.

I gave it a go, but I don’t know how I can add a legend to a grouped barchart. I tried legend=True, but that didn’t work.
I saw this github issue:
This says for a grouped barchart, it is hardcoded that there is no legend. So how can a legend be added? Maybe by getting the bokeh figure?

Then about trying to remove the xticks from the grouped barchart.
I was also unsuccessful. I found this:
Which comes down to: hv.Curve(range(11)).options(xticks=[(0, 'zero'), (5, 'five'), (10, 'ten')])
But .opts(xticks=[(0, 0)]) doesn’t work for grouped barcharts.
Is there a way to get rid of xticks with (grouped) barcharts?

I understand that you sometimes just want a legend instead of extra xticks to explain your categories.

This has been addressed in

1 Like

You can find a solution here:

Use .opts(multi_level=False):

import numpy as np
import pandas as pd
import holoviews as hv
pd.options.plotting.backend = 'holoviews'

df1 = pd.DataFrame({
    'x': np.random.rand(10), 
    'y': np.random.rand(10),

my_grouped_barplot = df1.plot(kind='bar')

# remove the 2nd categorical level with multi_level=False
# this will remove your x-ticks and add a legend