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

bokeh plot in jupyter slides not rendered corretly #4859

Closed
luoq opened this issue Jul 22, 2016 · 15 comments · Fixed by #6506
Closed

bokeh plot in jupyter slides not rendered corretly #4859

luoq opened this issue Jul 22, 2016 · 15 comments · Fixed by #6506

Comments

@luoq
Copy link

luoq commented Jul 22, 2016

bokeh export bug.zip

The plot in slides generated by following command ('bokeh export bug.slides.html') is not rendered correctly.

jupyter nbconvert --reveal-prefix=http://lab.hakim.se/reveal-js/ --to slides 'bokeh export bug.ipynb'

It should behave like 'bokeh export bug.html' generated by

jupyter nbconvert --to html 'bokeh export bug.ipynb'

bokeh info:
Python version : 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:53:06)
IPython version : 4.2.0
Bokeh version : 0.12.0
BokehJS static path : /home/lq/.local/anaconda3/lib/python3.5/site-packages/bokeh/server/static

@bryevdv
Copy link
Member

bryevdv commented Dec 10, 2016

ping @damianavila do you have any insights or comments?

@damianavila
Copy link
Contributor

I ca reproduce it, not sure why is failing yet. It is probably a confilct between reveal.js and bokeh... but I need to investigate further.

@bryevdv
Copy link
Member

bryevdv commented May 12, 2017

@luoq @damianavila any updates on this?

@damianavila
Copy link
Contributor

We should probably test with latest Bokeh and latest nbconvert to see if the issue persist.

@luoq
Copy link
Author

luoq commented May 15, 2017

This issue persists for bokeh 0.12.5

@00krishna
Copy link

+1 I have this problem when I try to export to pdf with nbconvert 5.1.1 and bokeh 12.5. The pdf gets generated but all of the plots are left out.

@bryevdv
Copy link
Member

bryevdv commented May 23, 2017

I can't reproduce this problem with a notebook saved with Bokeh 0.12.5 and nbconvert 5.1.1 on OSX. I can generate a static page with

jupyter nbconvert --to html Untitled7.ipynb

and I also get output (with plots) using

jupyter nbconvert --reveal-prefix=http://lab.hakim.se/reveal-js/ --to slides Untitled7.ipynb

Is there a failing notebook available someone can share?

@luoq
Copy link
Author

luoq commented May 24, 2017

@bryevdv you can try the zip file in first comment

@bryevdv
Copy link
Member

bryevdv commented May 24, 2017

the plain HTML works, the slides do not. Presumably because that notebook has sub-slides and mine didn't actually have real slide cells define. Looking at the JS console, the proximate cause is clear:

screen shot 2017-05-24 at 11 39 47

BokehJS is not getting loaded at all, which can also be confirmed by looking at the "sources" tab in the browser debug window. Unfortunately I have no idea why this would or could be, and probably won't be able to do much or anything about it without help from either the reveal or notebook folks. ping @damianavila

@bryevdv
Copy link
Member

bryevdv commented May 24, 2017

I will say, just to be clear, we don't currently and have not ever made any guarantees except for: in a running notebook, and in a plain HTML static rendered notebook. Obviously I'd love for things to work with reveal but if reveal and Bokeh don't work together that just may have to be noted as a known incompatibility.

@mansenfranzen
Copy link
Contributor

mansenfranzen commented Jun 13, 2017

I just came across the same issue having reveal.js not showing bokeh plots in the slide show which is sad considering the great functionality that bokeh, reveal and jupyter provide in combination for interactive data visualization (thanks to all of you guys - I really appreciate it!).

Fix via added bokeh.js import

Following @bryevdv comment about BokehJS failed to load within specified timeout and employing @luoq example notebook, I manually added the the bokeh.js import <script type="text/javascript" src="https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.js"></script> to the html header of 'bokeh export bug.slides.html' after the file was generated via jupyter nbconvert --to slides 'bokeh export bug.ipynb'.

This causes the bokeh plots to show up again. It indicates that the issue is somehow related to how bokeh.js is loaded/imported.

Fix via slide type within Jupyter

After experimenting with the slide types of the jupyter notebook, I figured that the key is to not skip output_notebook() in order to have the plots showing up. The output_notebook() is required for the related import of bokeh.js. Therefore, do not set it's slide show relevant cell slide type to skip. This information might help for a fix here @damianavila.

In order to hide output_notebook() for the slide show anyway, you can simply use the slide type notes.

Test material

For convenience, I added a zip with a working and non working version based on @luoq example notebooks.

Environment

I tested this with bokeh 0.12.5 and 0.12.6 with python 3.5.2 under ubuntu 16.4. with the newest jupyter and ipython packages.

@bryevdv
Copy link
Member

bryevdv commented Jun 13, 2017

@mansenfranzen This is incredibly valuable information, thank you very much for taking the time to investigate and write things up. It had escaped my notice that output_notebook was hidden or missing. It is indeed required in order to load BokehJS (which in turn is required for bokeh plots to show up).

Perhaps there is some other mechanism we can use to perform the work but otherwise hide the call, @damianavila any suggestions? Otherwise we can use this issue as a task to include this information in the documentation more prominently.

@damianavila
Copy link
Contributor

Otherwise we can use this issue as a task to include this information in the documentation more prominently.

I think documentation is the key here... if you skip a cell and try to convert to html or slides, that specific cell and the output of that cell (containing the bokeh.js) is not "passed" to the final output, preventing the correct loading of the bokeh plots. Putting output_notebook into the notes slide type is a reasonable workaround if you want to hide it. Modifying things like nbconvert or bokeh to handle this better is probably to much cost compare with the benefits that could potentially bring into the table.

@bryevdv
Copy link
Member

bryevdv commented Jun 20, 2017

I added a new section to the notebook chapter of the user's guide in 33d11cb This issue will automatically close when that PR is merged. @damianavila if there is something more/better to say than what I have added in that commit please let me know.

@damianavila
Copy link
Contributor

@damianavila if there is something more/better to say than what I have added in that commit please let me know.

LGTM as is.

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

Successfully merging a pull request may close this issue.

5 participants