9

I have a Bokeh chart in a Jupyter notebook, and I want to run custom Python whenever the Bokeh selection changes. It is very easy to run custom Javascript whenever the Bokeh selection changes using a source change callback, but I have no way to trigger Jupyter to respond to the event.

I think it is possible but poorly documented (see http://docs.bokeh.org/en/latest/docs/user_guide/server.html) to run a separate Bokeh server to receive the events. I want to avoid running a separate Bokeh server since the Jupyter server is already running.

bigreddot
  • 33,642
  • 5
  • 69
  • 122
John Jumper
  • 461
  • 3
  • 10

2 Answers2

0

I think you have to look at holoview. It is design for this. You can choose between different renderers : matpotlib, bokeh, plotly.

You can either use their methodology for simple plots or if it is more specific you can run bokeh apps.

As you can see almost all examples of bokeh are ported to holoviews Regards

Thomas PEDOT
  • 943
  • 1
  • 9
  • 18
0

This seems like a two-way communication between Bokeh object and Jupyter: https://docs.bokeh.org/en/latest/docs/user_guide/jupyter.html#notebook-handles

  1. Import standard functions and push_notebook()
  2. Create some plots and pass notebook_handle=True to show()
  3. Check that the handle is associated with the output cell
  4. Update some properties of the plot, then call push_notebook() with the handle
  5. Note that the output cell has changed (without being re-executed)

You might have to poll the variable you want to catch changing, as this does not look like an event handler, just mutual exposure.

Lorinc Nyitrai
  • 968
  • 1
  • 10
  • 27