Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotly responsiveness does not work #1556

Closed
MarcSkovMadsen opened this issue Aug 31, 2020 · 4 comments
Closed

Plotly responsiveness does not work #1556

MarcSkovMadsen opened this issue Aug 31, 2020 · 4 comments
Milestone

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Aug 31, 2020

My Pain

I would like it to be easy to use Panel to use the Python Data Viz ecosystem. One of the best plotting packages is Plotly.

But it currently does not work well in Panel.

For example Leonidas reports that he cannot get vertical responsiveness to work.

https://discourse.holoviz.org/t/plotly-backend-responsive-mode-only-works-horizontally/1150/4

Reproducible example

import panel as pn
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.layout.autosize=True
pp = pn.pane.Plotly(fig, config={'responsive': True}, sizing_mode="stretch_both")
app = pn.Column(
    '# A responsive plot ?',
    pn.Row(pp, pn.Spacer(width=10, background="blue"), background="lightgray", sizing_mode="stretch_both"),
    sizing_mode='stretch_both')
app.servable()

I run this with python -m panel serve 'scripts\horizontal_responsiveness.py' --dev --show

When it opens in Chrome I see

image

if I resize the window I see

image

Solution

  1. Make plotly resize initially.
  2. Support vertical responsiveness.

Additional Context

Related to #1514

@MarcSkovMadsen MarcSkovMadsen added the TRIAGE Default label for untriaged issues label Aug 31, 2020
@LeonvanKouwen
Copy link

@MarcSkovMadsen you mean support for vertical responsiveness, right? Horizontal seems to works, except for the initial resizing.

Besides the snippet in your post I have also tried using holoviews with the plotly backend, but I get the same problem; no vertical responsiveness.

I think good plotly support is important because the 3D interactive plotly plots are great and I am not aware of a good alternative.

@MarcSkovMadsen
Copy link
Collaborator Author

Thanks @LeonvanKouwen . I’ve updated the post above.

@philippjfr philippjfr added type: bug and removed TRIAGE Default label for untriaged issues labels Oct 12, 2020
@philippjfr philippjfr added this to the v0.10.0 milestone Oct 19, 2020
@philippjfr philippjfr modified the milestones: v0.10.0, v0.10.x Oct 27, 2020
@MarcSkovMadsen
Copy link
Collaborator Author

Additional Context: Reference Example Works

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

import pandas as pd
import plotly.express as px
import panel as pn

data = pd.DataFrame([
    ('Monday', 7), ('Tuesday', 4), ('Wednesday', 9), ('Thursday', 4),
    ('Friday', 4), ('Saturday', 4), ('Sunay', 4)], columns=['Day', 'Orders']
)

fig = px.line(data, x="Day", y="Orders")
fig.update_traces(mode="lines+markers", marker=dict(size=10), line=dict(width=4))
fig.layout.autosize = True

responsive = pn.pane.Plotly(fig, config={'responsive': True})

pn.Column('# A responsive plot', responsive, sizing_mode='stretch_width').servable()

image

@MarcSkovMadsen
Copy link
Collaborator Author

The thing missing is height responsiveness. But that is something to solve for Plotly.js.

I've created an issue plotly/plotly.js#5270 and close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants