question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nbconvert --to slides compatability offline mode

See original GitHub issue

I’d like to create a plotly figure in an ipython notebook in offline mode, export it using nbconvert --to slides, and view it using reveal.js. I think this is in principle possible because it works with mpld3:

Put the following in a cell in slides mode:

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import mpld3

mpld3.enable_notebook()

fig, ax = plt.subplots(subplot_kw=dict(axisbg='#EEEEEE'),figsize=(6,6))
ax.grid(color='white', linestyle='solid')

N = 50
scatter = ax.scatter(np.random.normal(size=N),
                     np.random.normal(size=N),
                     c=np.random.random(size=N),
                     s = 1000 * np.random.random(size=N),
                     alpha=0.3,
                     cmap=plt.cm.jet)

ax.set_title("D3 Scatter Plot", size=18);

Then run:

ipython nbconvert Untitled.ipynb --to slides --post serve

and you can use the plot interactively. This also works with bokeh, though I’d prefer to use plotly. I tried the following analogous code to generate a plotly graph:

import plotly
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
init_notebook_mode() # run at the start of every ipython notebook to use plotly.offline
iplot([{"x": [1, 2, 3], "y": [3, 1, 6]}],show_link=False)

This works in the notebook, but I when I try to export to slides get “Drawing…” displayed instead of the actual figure.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
astrojuanlucommented, Nov 5, 2018

Is this supposed to be a bug or a feature? It would be great to have autosize=True work in the slides, but perhaps there’s some limitation on the nbconvert side?

cc @tarokiritani @empet from https://github.com/plotly/plotly.py/issues/750

0reactions
manuelfigueiralcommented, Oct 9, 2018

I can’t get it to work. What does the plotly.js file need to include? All I get is the code to that makes the plot 😦

You can download the plotly.js by clicking here https://cdn.plot.ly/plotly-latest.min.js and hitting ctrl+s to save the page as javascript file (.js) (More info: https://plot.ly/javascript/getting-started/)

Make sure you rename the downloaded file to ‘plotly.js’ and put it in the same directory as the slides.html

credit to the answer that saved me: https://stackoverflow.com/questions/39136652/plotly-graph-does-not-show-when-jupyter-notebook-is-converted-to-slides

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using as a command line tool — nbconvert 7.2.7 documentation
In order to designate a mapping from notebook cells to Reveal.js slides, from within the Jupyter notebook, select menu item View –> Cell...
Read more >
Is there a way of converting jupyter notebook to slides without ...
Here's a somewhat hacky solution. Paste the following code into a new code cell, then execute the cell. Be sure to change the...
Read more >
Make your slides with IPython | Damian's blog - GitHub Pages
With the integration of nbconvert inside IPython, the last 1.0 release has the possibility to export the ipynb to other formats such as...
Read more >
nb-offline-convert - PyPI
The normal HTML exporter of nbconvert creates the HTML files that will fetch resources (javascript and css files) from CDN, and the WebPDF ......
Read more >
1 Jupyter / IPython notebook hints and tips
ipython nbconvert --to notebook --nbformat 3 mynotebook.ipynb ... It is now also used for slides and as lecturing medium.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found