Closed
Description
When calling plotly.offline.plot(), if we use output_type='file' and include_plotlyjs=False, the resulting html file is useless, as it cannot be rendered.
I'm using plotly 3.3.0.
import plotly
import plotly.graph_objs as go
#This generates a file that includes plotly.js, and works as intended
plotly.offline.plot([go.Scatter(x=[1, 2, 3], y=[3, 2, 6])],
filename='my-graph.html', output_type='file',
include_plotlyjs=True)
#This generates a file that doesn't include plotly.js, but fails to render
plotly.offline.plot([go.Scatter(x=[1, 2, 3], y=[3, 2, 6])],
filename='my-graph-nojs.html', output_type='file',
include_plotlyjs=False)
According to the documentation:
include_plotlyjs (default=True) -- If True, include the plotly.js
source code in the output file or string.
Set as False if your HTML file already contains a copy of the plotly.js
library.
I guess we are not supposed to use include_plotly_js=False and output_type='file' at the same time? If that is the case, the function should probably raise an error, rather than generating a useless file. However, I think the ideal solution would be to have the standalone html load plotly.js from an online CDN, like we do in Jupyter notebooks after calling init_notebook_mode(connected=False)
. So we would insert something like the following block in the html file:
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
Metadata
Metadata
Assignees
Labels
No labels