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

First of multiple plots blank in Jupyter when using iframe renderer. #3601

Open
cm-1 opened this issue Feb 21, 2022 · 3 comments
Open

First of multiple plots blank in Jupyter when using iframe renderer. #3601

cm-1 opened this issue Feb 21, 2022 · 3 comments
Labels
bug something broken P3 backlog

Comments

@cm-1
Copy link

cm-1 commented Feb 21, 2022

In trying to get Plotly plots to show in JupyterLab in my multi-environment setup, I came across two issues (#2508 and #2672) where one of the solutions mentioned is to set the default renderer to "iframe".

After consulting the Troubleshooting guide, I ultimately discovered that my mistake was. Even though I was using a 3.x version of JupyterLab, I still had to run jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyterlab-plotly because of my multi-environment setup. Additionally, ipywidgets had to be installed in the environment with Plotly rather than the one with Jupyter. Before finding that solution, however, I tested the iframe solution, and noticed what seems to be a small bug.

If the default renderer is "iframe" and two plots are created and shown in the same cell of a JupyterLab or Jupyter Notebook .ipynb notebook, the first plot will not render (blank space will be in its place), though the second cell will render fine. If one closes the .ipynb and then re-opens it, however, both plots will show up fine. Below is an example cell with two plots.

import plotly.express as px

import plotly.io as pio
pio.renderers.default='iframe'

df = px.data.tips()
fig = px.histogram(df, x="total_bill")
fig.show()

fig2 = px.histogram(df, x="day")
fig2.show()

A screenshot of the output:
image

If more than two plots are used, generally, only the last one will show up without reopening the file. I think I observed a few times where only the first one would be blank and all remaining would show up, but if this does happen, it is rare, since I have been unable to reproduce that.

I first observed this in Firefox 97.0, JupyterLab 3.29, and Plotly 5.1.0. However, I also tested with the latest version of Plotly (5.6.0) and observed the same behaviour.

@gvwilson
Copy link
Contributor

gvwilson commented Jul 3, 2024

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

@gvwilson gvwilson closed this as completed Jul 3, 2024
@cm-1
Copy link
Author

cm-1 commented Jul 19, 2024

Thank you for the message. I have tried the same code again in the newer versions, and a similar error occurs. The first plot still doesn't show up, but the second plot is rendered both in its place and where it should ordinarily go.

image

However, if each .show() call gets its own cell, then everything works fine.

I set up the new environment following the steps in https://plotly.com/python/getting-started/ for conda.

My Firefox version was 128.0, the Jupyter Lab version was 4.0.11, and the Plotly version was 5.22.0. I also tested with Jupyter Notebook 7.0.8 and saw the same behaviour. I can give more package version information if necessary.

Finally, I went through the steps in https://plotly.com/python/troubleshooting/#jupyterlab-problems to see if any of them would make a difference, but the same behaviour still occurred.

I do not personally rely on this behaving correctly; paired with the fact that no other users commented on this issue for a couple of years, it seems that not many people would be negatively impacted if this bug goes unfixed. Nonetheless, I thought I'd still report it just in case.

@gvwilson gvwilson reopened this Jul 19, 2024
@gvwilson gvwilson self-assigned this Jul 19, 2024
@gvwilson
Copy link
Contributor

thanks @cm-1 - I'll add it to our backlog, but it may be a while before someone can get to it.

@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added P3 backlog bug something broken labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

2 participants