Plotly plots are blank on mybinder startup?

Hi Chris et al! I’m loving the Jupyter ecosystem and recently have converted a Fastpages blog post to slides via RISE and am now trying to share them via mybinder!

When I open my notebook locally, my Plotly plots are already there – no cell execution required on startup to see the plots. (and the plots also show on Fastpages and nbdev docs.)

But in the deployed Binder notebook, they all appear blank at first, until you execute the cells. This is a challenge for sharing my slideshow, as I can’t have it auto-start in presentation mode, and instead have to instruct people “oh yea, be sure to do Kernel > Restart & Run All first to replace the blank spaces with plots. Then go back and start the slideshow.”

How to get Binder to show the plots on startup, just like my local Jupyter does?

(BTW, these are interactive plots; I’m not interested in static renderings via orca.)

Here’s the mybinder link for my slideshow: Binder

EDIT: Tried some “dark magic” to auto-run all cells on startup, but it doesn’t seem to have run on mybinder (worked fine locally). Plotly cells still blank until I manually Shift-Enter them. :cry:

Are they “untrusted” at first? The default stance in many clients with a real kernel behind them is to not just run any-old-code without user interaction.

In a postBuild (or slightly more cleanly from a reading perspective .binder/postBuild), you could try running:

#!/usr/bin/env bash
jupyter trust *.ipynb  # or wherever they are

Thanks for your suggestion! When I open the notebooks locally they are initially untrusted but the plotly plots still show anyway – these plots already exist in the .ipynb files as a set of javascript directives, so no code-running is requested and the plot show up anyway (locally).

I tried adding a .binder/postBuild and now the Plotly graphs are there now on mybiner! BUT it seems that RISE has been disabled somehow, and so there’s no way to run the slideshow. (??). (As in, the button to start the slideshow no longer appears and Alt-R has no effect.) How to fix that?

Quick note: appreciating what happens ‘Locally’ isn’t going to help you much debugging this in relating to Binder unless I am misunderstanding something. JupyterHub, which BinderHubs are a modified version of, and external domains I believe have a different security paradigm than running a notebook directly locally.

Another quick thing of general note that might help future readers of this thread is that Orca use is deprecated anyway. Use the newer Kaleido project now, see here.

I’ll have to play with Plotly and RISE-binder more to remind myself if I’ve even tried to have Plotly in there before and what I saw. Alternative option / Worse-case scenario, you could make the slideshow and plot displaying launches separate and use Voila to make the plot display more clean like a slide presentation. For example, go here and launch a binder session from that repo, click on the second demonstration notebook listed, ‘3D scatter plots via Plotly’, and when that is open click on the ‘Viola’ button on the toolbar across the top of the notebook in order to switch to a render where the code isn’t shown, reminiscent of a slide. There is a way to open the Voila rendering directly as demonstrated for a different example, specifically at the bottom of the top paragraph in the notebook ‘3D scatter plot using data in a file and Voila interface’ in the demonstration list.

1 Like

Thanks for sharing that! Glad to see someone else with experience sharing 3D scatter plots. I’d heard of Voila but hadn’t looked into it. This actually could serve as the answer to a different question I asked on the FastAI forums.

SOLUTION: Just on a lark, I thought I’d try re-installing RISE (even though it’s in my requirements.txt) after the jupyter trust, and it works!

$ cat .binder/postBuild 
#!/usr/bin/env bash
jupyter trust */*.ipynb  
pip3 install rise 

The same Binder link now auto-starts the slideshow, and all the Plotly plots are already showing! :partying_face:


Sorry, I should have mentioned: it you now also move your requirements.txt into .binder, you won’t need to pip install anything. If the requirements aren’t part of the talk, you should be good to go.

1 Like

Also, in this case, I meant specifically arbitrary untrusted JavaScript code, which is by extension capable of arbitrary untrusted kernel code kernel.execute. Any JS can do anything, hence the whole trust mechanism, such as it is.

1 Like

Thanks. I think I understand: to just show the slides “as is” would be ok? But in my case I think the requirements are part of the talk, i.e., if one wanted to re-execute any of the code, they’d get ImportErrors if the packages hadn’t been installed.

EDIT: Oh no, I see what you mean. As it is right now, I get import errors even for trying to use numpy! Because my requirements.txt is being ignored. So I’ll add a symlink to it in ./binder.

1 Like

In regards to widgets working (subject of your post at the FastAI forums), you also may want to see my responses here and the subsequent exchanges in that thread.

1 Like

OMG, that’s great. Will definitely try out some of that when I have more time. Thanks!

Great. Please post over there or on a new thread if you have any luck.