plotly / plotly/plotly.py

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

Aperta
#3,601 4 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug P3
Lingua principale
Python
Stelle
18.8k
Fork
2.8k
Merge medio
16h 26m
PR unite (30g)
21

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia eseguendo l’esempio Python fornito in un JupyterLab o Jupyter Notebook .ipynb con pio.renderers.default impostato su "iframe" e due chiamate a fig.show() nella stessa cella. Confronta il primo e il secondo grafico, quindi verifica il comportamento del renderer iframe quando il notebook viene riaperto. Il lavoro è completato quando entrambi i grafici vengono visualizzati immediatamente senza riaprire il file.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
jupyter-notebook, python
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.