Hi, thank you for this response.
Yes, it is not a complete reproducible example.
Some reproducible code to display the problem is:
import os
os.chdir("/home/jovyan/tutorial4/") # Choose a directory that exists
import plotly.io as pio
import numpy as np
import plotly.express
x=np.linspace(1,10)
y=np.linspace(1,10)
pio.renderers.default = 'iframe'
plotly.express.scatter(x=x,y=y, color = [str(m) for m in x])
It seems clear that the change to a new working directory is the issue.
I’m not sure there’s a way to tell Jupyter or Plotly where to look for the images if the os directory is changed. I don’t really need to change the os dir, though,
it’s just a convenience thing to make it easier to access files in the given directory, so this isn’t a huge blocker for me.
Your comment about pio.renderers
is helpful. I thought that the variable was a constant and renderers would be the same across platforms. My variable shows:
['plotly_mimetype', 'jupyterlab', 'nteract', 'vscode',
'notebook', 'notebook_connected', 'kaggle', 'azure', 'colab',
'cocalc', 'databricks', 'json', 'png', 'jpeg', 'jpg', 'svg',
'pdf', 'browser', 'firefox', 'chrome', 'chromium', 'iframe',
'iframe_connected', 'sphinx_gallery', 'sphinx_gallery_png']
In particular, since iframe
appears on that documentation page as a standard built-in renderer in the documentation you linked, it’s surprising that it’s not present in your version. My code worked before updating to more recent versions of Plotly, so maybe that renderer is no longer present and they have not updated the documentation. Otherwise, I am not sure why you don’t have iframe
installed or how you should install it.
When I change it from iframe
to notebook
it seems to work.
You seem to want to do something with pio.renderers
, yet don’t mention that in the text of the post or title (see section below)?
I am creating a documentation website and I intend to use nbconvert to convert my Jupyter notebook into HTML. I seem to remember that the default Plotly renderer stores the plots in a place that the nbconvert tool doesn’t see/can’t find, and so the HTML page has a blank space where the plot should be, so I was trying to find a renderer which would embed the plot directly into the notebook.
The title is confusing.
Sorry, I meant figure. But a plot is of course a kind of image