Closed parente closed 4 years ago
Thanks for the quality report @parente
~I'm able to see the same thing locally. It appears to be a race condition where the plot cell is executed (on refresh) before the output_notebook cell is finished loading BokehJS and creating the ~window.Bokeh
object.
Upon further investigation, it appears that the issue is the bokeh.io.output_notebook
call embeds some JS in the notebook as part of a mime bundle. When the page is reloaded, this JS is evaled before the notebook is rendered, so the BokehJS loading is stopped here: https://github.com/bokeh/bokeh/blob/13baccbb2835f7d5831c22b5cf68214e89c02618/bokeh/core/_templates/autoload_js.js#L79
@parente a work-around is to use
from bokeh.plotting import output_notebook, figure, show
output_notebook(hide_banner=True)
which will load BokehJS without checking for the notebook content being reading, so that plots will render correctly on reloading.
Thanks @canavandl. That does indeed workaround the problem.
noting still an issue with 1.0.0next but workaround still works too
I have a similar problem, when I refresh the page of my Jupyter notebook, no plots are shown. As suggested, I am using
output_notebook(hide_banner=True)
But this does not solve the problem. I'd like the plots to show automatically in its latest state before refreshing, like matplotlib or seaborn do...
@cuspime certainly we would like that to work to, though please understand the situation is very different and much more complicated than with MPL or seaboard, which only store simple PNGs. Bokeh has an entire separate JavaScript runtime that needs to execute and re-constitute live interactive plots, and that has to integrate with the notebook/jupyterlab which itself is a huge and complicated JavaScript runtime.
This used to work. I am not sure what changed (on either side) to affect things. I will relay the same advice I did in #29 which is to raise a new issue (linked to this one) in the main Bokeh repo in order to raise the visibility on this issue (this repo does not see as much attention)
I did some debugging today and there are several issues that need resolving to make the broad problem go away. I also noticed that integration with jupyter widgets doesn't fully work after a reload (can't update state), which significantly raises the priority of this issue to me.
@mattpap did you mean to add this to 2.0.2? Or are we not tracking versions? (I have no idea what intentions here re: versioning this repo)
The intention is to have 2.0.1 of jupyter_bokeh as soon as I sort out new tokens.
I can add a new token to the vault if that's simplest
opts = dict(plot_width=250, plot_height=250, min_border=0)
p1 = figure(**opts) r1 = p1.circle([1,2,3], [4,5,6], size=20)
p2 = figure(**opts) r2 = p2.circle([1,2,3], [4,5,6], size=20)
get a handle to update the shown cell with
t = show(row(p1, p2), notebook_handle=True)