Skip to content

Cannot specify figure width with Jupyterlab #2324

Open
@emmanuelle

Description

@emmanuelle
Contributor

Jupyterlab always resizes the width of the figure to the width of the notebook. When executing the code below, one can see the figure generated with the correct figure for a very short time, and then it resizes to the full width. Is it related to recent changes to make plotly figures more reactive?

import plotly.graph_objects as go
fig = go.Figure(go.Scatter(y=[2, 3]))
fig.update_layout(width=100)
print(fig)
fig.show()

image

Inside a fresh environment, with plotly / jupyterlab / widgets versions of our Readme.

No error messages in the console.

Activity

emmanuelle

emmanuelle commented on Mar 27, 2020

@emmanuelle
ContributorAuthor

Could this be a consequence of
plotly/plotly.js#4392 ? @antoinerg

antoinerg

antoinerg commented on Mar 27, 2020

@antoinerg
Contributor

@emmanuelle my guess is that it is not. I assume responsive is set to True by default? What happens if you specify both width AND height?

Info about plotly/plotly.js#4392

PR plotly/plotly.js#4392 is meant to resolve Promises returned by resize operations (ie. Plots.resize) that are dropped because a new request came in before the work could be done. Prior to this PR, those Promises would be pending forever. With the PR, those Promises will all resolve at the same time when the actual resize operation is performed/finished.

emmanuelle

emmanuelle commented on Mar 27, 2020

@emmanuelle
ContributorAuthor

thank you @antoinerg I will try to set both the width and height

emmanuelle

emmanuelle commented on Mar 28, 2020

@emmanuelle
ContributorAuthor

Thanks for the great tip @antoinerg indeed if you specify both width and height it works. Does this give you a hint about what is happening?

ned2

ned2 commented on Nov 12, 2020

@ned2
Contributor

Running into this problem also. Can confirm that setting both width and height makes the width be applied.

Would be great to get a fix in for this. It took me a while to convince myself that there was some kind of a bug (as opposed to user error) and JupyterLab is increasingly becoming the default notebook experience.

self-assigned this
on Jun 18, 2024
removed their assignment
on Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @emmanuelle@antoinerg@gvwilson@ned2

        Issue actions

          Cannot specify figure width with Jupyterlab · Issue #2324 · plotly/plotly.py