plotly / plotly/plotly.py

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

オープン
#3,601 コメント 4 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P3
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、pio.renderers.defaultを"iframe"に設定し、1つのセル内でfig.show()を2回呼び出す状態で、提供されたPythonの例をJupyterLabまたはJupyter Notebook .ipynbで実行します。1つ目と2つ目のプロットを比較し、その後、ノートブックを再度開いたときのiframe rendererの動作を確認します。ファイルを再度開かなくても両方のプロットが直ちにレンダリングされれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
jupyter-notebook, python
領域
data-visualization
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。