legend not working for bar plot with Plotly backend
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 124
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 1
Description
I would expect the `legend` attribute to also work for the Plotly backend in the example below. But it does not.

```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=True, height=500, legend='bottom')
hvplot.extension("plotly")
table.hvplot.bar(stacked=True, height=500, legend='bottom')
```
## HoloViews
I've tried to replicate this using HoloViews. But it seems the corresponding `legend_position` is only supported for the `matplotlib` and `bokeh` backends. There is an existing FR in HoloViews to support `legend_position` for the Plotly backend. See https://github.com/holoviz/holoviews/issues/5221
It is possible to position the Plotly legend using a hook though.
```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)
def hook(plot, element):
# https://plotly.com/python/legend/#legend-positioning
fig = plot.state
fig["layout"]["legend"]=dict(
yanchor="top",
y=0.99,
xanchor="left",
x=0.01
)
plot = hv.Bars(table, kdims=["yr", "origin"], vdims="mpg").opts(stacked=True, height=500, width=1000, hooks=[hook])
import panel as pn
pn.extension()
pn.panel(plot).servable()
```

## 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
Assessment
This issue has not been assessed yet.