Getting PlotlyJS to show up for online jupyter notebooks

Does anyone know a way to get the plots generated by PlotlyJS inside notebooks to show up online? (they render fine running in local host). In Github or nbviewer they are always blank for me

e.g
http://nbviewer.jupyter.org/github/bcbi/julia_tutorials/blob/master/nnmf/nnmf_classic3_clustering.ipynb

I looked at the examples at https://github.com/JuliaPlots/ExamplePlots.jl and I don’t see any working case where plotlyjs is the backend. Did I miss one?

I also tried using nbconvert to html and same - I can see some errors in the developer console of Chrome.

Is this a know limitation?

We keep a collection of notebooks as examples for students, and I often use plotlyjs… but not being able to show the result/plots online defeats the purpose of the notebooks…

1 Like

They render fine for me, although that was a few months ago:

Yeah, notebook viewer usually works.

I notice that there’s no output after the using PlotlyJS cell. When the package is first imported it generates and runs some initialization javascript that’s important to the functioning of the plots. If you get rid of that output, your plots will still work locally (because the init code was already run), but if you re-open the notebook the plots may not work until you cause the init javascript to be re-run by running the using cell again.

Perhaps you got rid of that output in the notebook that nbviewer is loading? If so, try re-running that cell and leaving the output (you should see some text from PlotlyJS).

3 Likes

That was exactly the issue! I don’t recall getting rid of the output of that line intentionally, but once I made sure that output was part of the online version, it worked. Thank you!

Yep – this is 100% correct. I wish I had a better solution to this, but that javascript needs to be executed whenever the browser loads the notebook. The only way this can happen is if that cell doesn’t get re-run and the js removed.