# Plotly plots are blank on mybinder startup?

**URL:** <https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953>\
**Category:** repo help\
**Created:** [April 28, 2021, 4:51am UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953 "2021-04-28T04:51:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![drscotthawley](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/drscotthawley/32/4276_2.png) [@drscotthawley](https://discourse.jupyter.org/u/drscotthawley)\
**Post date:** [April 28, 2021, 4:51am UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/1 "2021-04-28T04:51:54Z")

</div>

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](https://mybinder.org/v2/gh/drscotthawley/talks/HEAD?filepath=SoTL_3DClass_April_2021%2FJoy-Of-3D-Slides.ipynb)

**EDIT:** Tried some “dark magic” to [auto-run all cells on startup](https://stackoverflow.com/questions/31984196/jupyter-notebook-run-all-cells-on-open), but it doesn’t seem to have run on mybinder (worked fine locally). Plotly cells still blank until I manually Shift-Enter them. 😢

---

<div class="post-metadata">

**Author:** ![bollwyvl](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bollwyvl/32/904_2.png) [@bollwyvl](https://discourse.jupyter.org/u/bollwyvl)\
**Post date:** [April 28, 2021, 11:58am UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/2 "2021-04-28T11:58:29Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![drscotthawley](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/drscotthawley/32/4276_2.png) [@drscotthawley](https://discourse.jupyter.org/u/drscotthawley)\
**Post date:** [April 28, 2021, 3:03pm UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/3 "2021-04-28T15:03:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [April 28, 2021, 3:47pm UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/4 "2021-04-28T15:47:28Z")

</div>

> [@drscotthawley](#):
>
> 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

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](https://github.com/plotly/orca/issues/150#issuecomment-677776942).

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](https://github.com/fomightez/3Dscatter_plot-binder) 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.

---

<div class="post-metadata">

**Author:** ![drscotthawley](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/drscotthawley/32/4276_2.png) [@drscotthawley](https://discourse.jupyter.org/u/drscotthawley)\
**Post date:** [April 28, 2021, 5:32pm UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/5 "2021-04-28T17:32:33Z")

</div>

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](https://forums.fast.ai/t/fastpages-ipywidgets-wont-work-in-exported-blog-right/87556/4).

**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!

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

```

[The same Binder link](https://mybinder.org/v2/gh/drscotthawley/talks/HEAD?filepath=SoTL_3DClass_April_2021%2FJoy-Of-3D-Slides.ipynb) now auto-starts the slideshow, and all the Plotly plots are already showing! 🥳

---

<div class="post-metadata">

**Author:** ![bollwyvl](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bollwyvl/32/904_2.png) [@bollwyvl](https://discourse.jupyter.org/u/bollwyvl)\
**Post date:** [April 28, 2021, 5:46pm UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/6 "2021-04-28T17:46:44Z")

</div>

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.

[https://repo2docker.readthedocs.io/en/latest/usage.html?highlight=.binder#where-to-put-configuration-files](https://repo2docker.readthedocs.io/en/latest/usage.html?highlight=.binder#where-to-put-configuration-files)

---

<div class="post-metadata">

**Author:** ![bollwyvl](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bollwyvl/32/904_2.png) [@bollwyvl](https://discourse.jupyter.org/u/bollwyvl)\
**Post date:** [April 28, 2021, 5:48pm UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/7 "2021-04-28T17:48:56Z")

</div>

> [@drscotthawley](#):
>
> so no code-running is requested and the plot show up anyway (locally).

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.

---

<div class="post-metadata">

**Author:** ![drscotthawley](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/drscotthawley/32/4276_2.png) [@drscotthawley](https://discourse.jupyter.org/u/drscotthawley)\
**Post date:** [April 28, 2021, 5:54pm UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/8 "2021-04-28T17:54:53Z")

</div>

> [@bollwyvl](#):
>
> If the requirements _aren’t_ part of the talk,

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`.

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [April 28, 2021, 6:16pm UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/9 "2021-04-28T18:16:34Z")

</div>

> [@drscotthawley](#):
>
> This actually could serve as the answer to a [different question I asked on the FastAI forums](https://forums.fast.ai/t/fastpages-ipywidgets-wont-work-in-exported-blog-right/87556/4).

In regards to widgets working (subject of your post at the FastAI forums), you also may want to see my responses [here](https://discourse.jupyter.org/t/hosting-interactive-jupyter-html-file-with-ipywidgets-on-github-as-web-page/8361/2) and the subsequent exchanges in that thread.

---

<div class="post-metadata">

**Author:** ![drscotthawley](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/drscotthawley/32/4276_2.png) [@drscotthawley](https://discourse.jupyter.org/u/drscotthawley)\
**Post date:** [April 28, 2021, 6:21pm UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/10 "2021-04-28T18:21:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [April 28, 2021, 6:23pm UTC](https://discourse.jupyter.org/t/plotly-plots-are-blank-on-mybinder-startup/8953/11 "2021-04-28T18:23:17Z")

</div>

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