Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotly not rendering in sphinx #145

Closed
rkdarst opened this issue Apr 27, 2022 · 3 comments
Closed

Plotly not rendering in sphinx #145

rkdarst opened this issue Apr 27, 2022 · 3 comments

Comments

@rkdarst
Copy link
Collaborator

rkdarst commented Apr 27, 2022

I found this that implied the problem was related to sphinx_rtd_theme:
readthedocs/sphinx_rtd_theme#788
or maybe this in Sphinx: sphinx-doc/sphinx#9563

The first one says it is fixed, but we use the latest version but it still doesn't work. I'll keep investigating and use this to track.

One thing I'll try is using a different theme.

@ArgonSilicon
Copy link
Collaborator

It looks like that changing the plotly renderer to "png" will make the plots visible on readthedocs pages.

fig.show(renderer="png") for single plot. There should be way to set the default for whole notebook.

@rkdarst
Copy link
Collaborator Author

rkdarst commented Apr 27, 2022

That would work!

If you want plotly (which I think would be nice, see this: https://myst-nb.readthedocs.io/en/latest/render/interactive.html#plotly - it is actually still interactive), I got it working with sphinx-book-theme (and maybe one other thing, I forget now. It might have been downgrading mathjax, see the first warning that is here: https://www.sphinx-doc.org/en/master/usage/extensions/math.html#module-sphinx.ext.mathjax . Or maybe it was using myst-parser...
I'll figure out tomorrow.

How much would you value plotly showing up?

Overall, sphinx_rtd_theme is starting to show its age and hasn't been updated as often as I would like. It's not too bad yet, but it wouldn't be too bad to find a replacement.

@rkdarst
Copy link
Collaborator Author

rkdarst commented Apr 28, 2022

OK, this is what makes interactive plotly plots work:,

  • myst_nb instead of nbsphinx
  • Add to conf.py:
    # needed for plotly, see https://myst-nb.readthedocs.io/en/latest/render/interactive.html#plotly
    html_js_files = ["https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"]
    

... and it works with sphinx_rtd_theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants