quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.77k stars 309 forks source link

Plotly plot not anymore rendered when using jupyter notebook in quarto #1043

Closed scalgary92 closed 2 years ago

scalgary92 commented 2 years ago

Thanks for the great work I have uploaded the newest quarto version 498. I used to be able to render my jupyter notebook with plotly plots in html now I have the following message Unable to display output for mime type(s): application/vnd.plotly.v1+json How can I revert to previous versions of quarto? All still works fine in qmd file but I would prefer to stick to Jupyter notebook

Thanks

Checklist

When filing a bug report, please check the boxes below to confirm that you have provided us with the information we need. Have you:

jjallaire commented 2 years ago

You can get old versions of Quarto here: https://github.com/quarto-dev/quarto-cli/tags

However, that error message looks to me like you have executed a plotly plot within VS Code (which saves the plot as JSON internally, which Quarto currently doesn't know how to render). If you set the rendered to "notebook" as demonstrated here it should work as expected:

import plotly.express as px
import plotly.io as pio
pio.renderers.default = "notebook"
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.show()
scalgary92 commented 2 years ago

Thanks a lot. strange but the same code wasn't working on 499 but is working on 501.

jjallaire commented 2 years ago

I've been making some changes related to this over the past hour or so! Just updated the plotly docs to mention a variation of the workaround that should provide good rendering both in VS Code and in Quarto rendered HTML: https://quarto.org/docs/interactive/widgets/jupyter.html#plotly