Interactive plots inside a python application


I am new to Bokeh and need some hints into the right direction for my purpose. I want to generate interactive 2D-plots using Bokeh. A python application generates the data. I use it for personal use only.
As of now, I am using Spyder to develop the application and run it from inside Spyder. The application processes some data, and creates a plot, so far without any interaction.

The interaction I want to add is that I “select” an x-axis value (ideally by clicking any data point/glyph having the x-axis value I want to select). The x-axis contains date or date/time values. All data belonging to the selected x-axis value should then be displayed in a second “plot”, which could in the simplest form be a PreText widget, for example.

If I unterstand the User Guide correctly, I need to use a Bokeh server to be able to use callbacks with python code. Is this correct? My problem is that I don’t really understand how I could make this function with my python application. According to the user guide there is the possibility to use a “single module format” or a “directory format”.
My application consists of a number of modules.

  • Do I have to use the “directory format”?
  • Do I have to put my application inside this directory structure?
  • Is it still possible to run it from Spyder?

How do I have to go about?
Thanks for any help.

The answer is “yes” to all questions.
A slight note on the format questions - you can embed Bokeh as a library, then your app can have any structure. Documentation mentions that scenario.

Spyder is just as IDE, it has no (or shouldn’t have) any effect on how you go about your Python code. But given that it has some support for plots, it may be worth mentioning that interactive Bokeh plots probably won’t work in Spyder and you will have to use a regular web browser for them.

1 Like