Rishikesh Kakade
Rishikesh Kakade

Reputation: 71

Bokeh: How to plot two lines with two axes on plot?

I am aware it is possible to graph more than one line glyph on a bokeh graph as demonstrated here.

It is also possible to have two y-axis on a single plot as responses mentioned here.

I would like to be able to effectively combine these and create a single graph that is capable of plotting two lines, each corresponding to distinct axes. It should be possible to selectively adjust the views of the two lines independently.

In my specific case, I have sensor data along with error codes for that data. I would like to graph the values collected by the sensor and overlay it with the error code at that time. I could not simply follow something like this as panning the view would move both lines simultaneously and there exists drift in the sensor data over time. I need to be able to move the error code plot up and down.

Here is an example

Upvotes: 1

Views: 436

Answers (1)

bigreddot
bigreddot

Reputation: 34568

"Twin" axes in Bokeh are always linked according to the initial axis ranges. Thereafter, interactive panning or zooming, etc, will always update both axes to maintain the original relative scale. There is no mechanism to disable this behavior for range updates from interactive UI tools. It is potentially possible you could programmatically update the range for one of the axis (e.g. from a CustomJS callback on a button) without updating the other, but you would just have to experiment and see (i.e. things were not designed with this in mind, but it may work).

Upvotes: 1

Related Questions