Bokeh 3.1.1 does not render any more in jupyter notebook

I have code that works fine with Bokeh 2.4.3, notebook 6.5.3 and Ipython 8.11.0

The same code does not render anything with Bokeh 3.1.1, notebook 6.5.4, Ipython 8.12.2 and jupyter 1.0.0 and jupyter_bokeh 3.0.7 installed.

Here is the full, self-contained code:

import bokeh
print("bokeh", bokeh.__version__)
import bokeh.io
import bokeh.plotting
import numpy as np
import notebook, IPython, jupyter, jupyter_bokeh
print("notebook", notebook.__version__, "IPython", IPython.__version__, "jupyter", jupyter.__version__, jupyter_bokeh.__version__)
bokeh.io.output_notebook()

x=np.arange(100)
y1=np.random.randn(100)
y2=np.random.randn(100)
source = bokeh.models.ColumnDataSource(data=dict(x=x,y1=y1,y2=y2))
xdr = bokeh.models.Range1d(start=0, end=99)
p1 = bokeh.plotting.figure(height=100, width=600,tools="xpan,box_zoom,wheel_zoom,xbox_select,reset,undo", toolbar_location="above",x_axis_location="above", x_range=xdr)
p1.line('x', "y1", source=source)
p2 = bokeh.plotting.figure(height=100, width=600,tools="", toolbar_location=None,x_axis_location="below", x_range=xdr)
p2.line('x', "y2", source=source)
fig=bokeh.layouts.gridplot([p1,p2], ncols=1)
bokeh.plotting.show(fig)

This shows the “BokehJS 3.1.1 successfully loaded.” message but no other output whatsoever.

The Javascript console shows the following error message for the tab:

Uncaught (in promise) TypeError: this.plot_view.state is undefined
    connect_signals https://cdn.bokeh.org/bokeh/release/bokeh-3.1.1.min.js:648
    build_views https://cdn.bokeh.org/bokeh/release/bokeh-3.1.1.min.js:224

This seems to be some issue with gridplot. There are lots of tests and examples around gridplot and this usage seems consistent with those, but I don’t really use gridplot so I can’t say for certain if it is a usage issue, or a bug. I’d encourage you to make a GitHub Issue with full details.

In any case, a workaround that works for me is to use column instead:

fig=bokeh.layouts.column(p1, p2)

@johann-petrak Actually this (very strangely) has something to do with the “undo” tool. Your code generates output for me if I only remove “undo” from the list of tools. [1] I’d definitely suggest filing a bug report.

cc @mateusz


  1. NB I am using Bokeh 3.3 ↩︎

Thanks a lot … yes I can confirm that the workarounds … work:

  • removing the undo tool
  • and/or using bokeh.layouts.column(p1, p2)

However the second method makes the graph looks somewhat different, so for me removing the undo tool is the better option.

Thanks again!

Created issue [BUG] Gridplot figure does not render · Issue #13436 · bokeh/bokeh · GitHub

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.