☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Revealing the structure of a bokeh model

Showcase
jeremy9959
jeremy9959

I’ve been trying to learn about how Bokeh is put together, and in the course of that wrote this (relatively) small piece of code that draws the structure of a bokeh model. For example, here
is a bokeh plot of a sin wave with some added noise:

and here is the structure of that model:

Although not visible in this static image, if you hover over the nodes you can see which attribute of the parent the submodel is attached to.

The trickiest part of this is that there isn’t a natural way to iterate over the submodel structure. I got around this by using model.references() to construct, for each submodel, the subset of all models that
are children of that submodel, constructing the graph of the partial order for the inclusion relation, and then finding the transitive reduction of that graph using a networkx algorithm.

The code for this is here.

⌁   Link to post
Bryan
Bryan

This is really fantastic! Thinking out loud if it might make sense to add this as a utility function to Bokeh itself, so that anyone could interrogate their object graph. What do you think?

⌁   Link to post
jeremy9959
jeremy9959

In working with this further, I found that a basic assumption I had made – that the models form a directed acyclic graph - -doesn’t hold for complicated models involving selections and callbacks. So until I figure out a general implementation I’m going to take this code down.

⌁   Link to post

End of archived discussion · Replies are disabled