Plotly backend responsive mode only works horizontally

I want plots that scale to the window size both horizontally and vertically (aka responsive). I am half-way with the following snippet:

import holoviews as hv
import panel as pn 

pn.extension('plotly') 
hv.extension('plotly')

plot = hv.Points(([0, 1, 2], [4, 5, 6])).opts(responsive=True)
pn.serve(pn.panel(plot))

The width is responsive indeed. The problem is that the the height is fixed. Any ideas?

1 Like

Maybe take a look at the Panel Plotly documentation

https://panel.holoviz.org/reference/panes/Plotly.html

and experiment a bit from that.

Maybe you have to get the Plotly object, set the autosize and add the config to a specific Plotly pane.

Thanks for the suggestion. I played around a little but didn’t get anywhere. I get the feeling it is a plotly issue, as I didn’t see a xy responsive plotly graphs example yet.

1 Like

I played around a bit more and the problem is caused when invoking panel after all. I can get a plotly responsive plot with this code:

import plotly.graph_objects as go
import plotly.io as pio
pio.renderers.default = "browser"

fig = go.Figure()
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[1, 3, 1]))
fig.show()

But when I wrap it in a panel (I tried some different ways) l get only horizontal responsiveness. Is this a bug?

fig = go.Figure()
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[1, 3, 1]))
pp = pn.pane.Plotly(fig, config={'responsive': True})
pn.serve(pn.Column('# A responsive plot', pp, sizing_mode='stretch_both'))
1 Like

I believe this is a bug. I’ve reported it here https://github.com/holoviz/panel/issues/1556. Feel free to add your comments.

FYI. @philippjfr