Enable legend when using bars with multiple columns

Hi pyviz ninjas! I have a question regarding plotting bar charts. Assume I have the following data set:

tmp = pd.DataFrame({
    "foo": [1,2,3],
    "bar": [4,2,6]
}, index=["id1", "id2", "id3"])

then doing something like tmp.hvplot.bar() plots bars such that the column names (foo and bar) are rendered in each group (for each ID). How can I avoid that and use a legend for the colors instead?

Support for this was added in https://github.com/holoviz/holoviews/pull/4183 which hasn’t yet been released. In future I think you’ll be able to activate this with tmp.hvplot.bar(multi_level=False)

1 Like

You can install the latest version of HoloViews as follows:

pip install git+https://github.com/holoviz/holoviews.git

Then you can use .opts(multi_level=False) like this: