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

Blank plot in html using nbconvert (basic template) #1033

Closed
ltetrel opened this issue Jun 14, 2018 · 8 comments
Closed

Blank plot in html using nbconvert (basic template) #1033

ltetrel opened this issue Jun 14, 2018 · 8 comments

Comments

@ltetrel
Copy link

ltetrel commented Jun 14, 2018

Hi everyone,

I know that to convert a jupyter notebook (.ipynb) to an html I can use this command :

jupyter nbconvert --to html --template full myNotebook.ipynb

In this case I can successfully see my plot in the resulting html (myNotebook_full.html in
myNotebook.zip).

However, when I am trying to convert it using the basic template, there is a blank space instead of the plot

(myNotebook_basic.html in myNotebook.zip).

jupyter nbconvert --to html --template basic myNotebook.ipynb

missing

Do you have an idea why ?

Thanks all for your work and support !

@ltetrel
Copy link
Author

ltetrel commented Jul 6, 2018

I finally managed to resolve my issue.
I just needed to include the following scripts at the top of my .html template file :

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

@astrojuanlu
Copy link
Contributor

For Sphinx docs that use themes without jQuery on <head>, this workaround is fragile and does not always work in all browsers or all the times. We are tracking it accross several places:

spatialaudio/nbsphinx#128, poliastro/poliastro#281, readthedocs/readthedocs.org#4367

Perhaps this is something that could be worked on the Plotly side? Could we please reopen this?

@jonmmease
Copy link
Contributor

Hi @Juanlu001, sure we can reopen this.

So it looks to me like the JavaScript block emitted by plotly.py on init_notebook_mode expects requirejs to be active, but I don't see how it's using or altering jquery.

script_inject = (
''
'<script type=\'text/javascript\'>'
'if(!window.Plotly){{'
'define(\'plotly\', function(require, exports, module) {{'
'{script}'
'}});'
'require([\'plotly\'], function(Plotly) {{'
'window.Plotly = Plotly;'
'}});'
'}}'
'</script>'
'').format(script=get_plotlyjs())

Could you summarize your current understanding of what's going wrong?

Another approach would be to use the fact the FigureWidget is an ipywidget. I've successfully embedded FigureWidget instances for nbviewer, and it's supposed to be possible in sphinx as well (https://ipywidgets.readthedocs.io/en/stable/embedding.html) though I haven't tried that yet.

@astrojuanlu
Copy link
Contributor

Could you summarize your current understanding of what's going wrong?

Yes! Please read my comment here:

readthedocs/readthedocs.org#4367 (comment)

@jonmmease
Copy link
Contributor

Hi @Juanlu001, just following up. I haven't studied the thread in detail, but it seems like folks are making progress on the RTD side. Is there anything you see at this point that you need from plotly.py?

@astrojuanlu
Copy link
Contributor

@jonmmease Thanks! Progress is slow but I think it's been acknowledged that it's an issue on the RTD side - let's hope someone gives it the final push.

@hyamanieu
Copy link

Just for your information, I found that using holoviews method as follows fixed the exporting issue, even if I'm not using holoviews in the notebook at all (you'll need to conda install or pip install a compatible holoviews)

import holoviews as hv
hv.extension('plotly')

@gvwilson
Copy link
Contributor

Hi - we are currently trying to tidy up Plotly's public repositories to help us focus our efforts on things that will help users most. Since this issue has been sitting for several years, so I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our backlog. Thanks for your help - @gvwilson

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

5 participants