plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

Setting export PLOTLY_RENDERER=notebook_connected+vscode doesn't work as expected

Open ice1x opened this issue 3 years ago • 0 comments

plotly==5.9.0

Test case: 1)export PLOTLY_RENDERER=notebook_connected+vscode 2)run VSCode and create ipynb with content:

import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", marginal_y="violin",
           marginal_x="box", trendline="ols", template="simple_white")
fig

3)Press "run all" twice

Actual: First time ipynb generated with plotly block content type: text/html Second time - application/vnd.plotly.v1+json

Expected: Both times text/html - as it works if i use this workaround:

import plotly.io
plotly.io.renderers.default = 'notebook_connected+vscode'

Note:

  • After setting PLOTLY_RENDERER=notebook_connected+vscode env variable i see them in env list.
  • In VSCode if run:
import plotly.io
print(plotly.io.renderers.default)

i see correct renderer: 'notebook_connected+vscode' but seems like this is not enough, still need to run plotly.io.renderers.default = 'notebook_connected+vscode' to get this workaround applied.

Seems like some special actions executed during setting plotly.io.renderers.default = 'notebook_connected+vscode' in code in comparison with reading them from environment, i suspect some magic is absent there: https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/io/_renderers.py#L455

ice1x avatar Aug 03 '22 14:08 ice1x