holoviz / holoviz/hvplot

multiindex not working for bar plot with Plotly backend

Open
#1,036 0 comments 0 reactions 0 assignees View on GitHub
upstream
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

I would expect to be able to use a `MultiIndex` with a `bar` plot for the Plotly backend in the same way as for the Bokeh backend. But it does not work.

![image](https://user-images.githubusercontent.com/42288570/224509392-689660b8-2955-494f-824c-7eceaa911863.png)

```python
import hvplot.pandas # noqa

from bokeh.sampledata.autompg import autompg_clean as df

table = df.groupby('yr').mean(numeric_only=True)
table.head()

table = df.groupby(['yr', 'origin']).mean(numeric_only=True)
table.head()

hvplot.extension("bokeh")
table.hvplot.bar(stacked=False, height=500, rot=90)

hvplot.extension("plotly")
table.hvplot.bar(stacked=False, height=500, rot=90)
```

I've been changing for example the `height` because maybe the x-axis is correct but just display outside the "visible" area. But I've not been able to get it working.

## HoloViews

I can see that there is also an issue in HoloViews

```python
import holoviews as hv # noqa

hv.extension("plotly")

from bokeh.sampledata.autompg import autompg_clean as df

table = df.groupby(['yr', 'origin']).mean(numeric_only=True)
plot = table.hvplot.bar(stacked=False, height=500, width=1000)
plot = hv.Bars(table, kdims=['yr', 'origin'], vdims="mpg").opts(stacked=False, height=500, width=1000)

import panel as pn

pn.extension()

pn.panel(plot).servable()
```

![image](https://user-images.githubusercontent.com/42288570/224530639-bbf312b3-d847-42a5-90ce-e62ad87be3cb.png)

I've reported it here https://github.com/holoviz/holoviews/issues/5657

## Additional Context

I've been working on improving the `bar` docs. As a part of this I try changing the plotting backend. I would really, really like the documentation to work for all plotting backends. That is what I would expect as a user.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.