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.