PyRsquared
PyRsquared

Reputation: 7338

How to add extra subplots sharing x-axis using bokeh?

I currently have a simple line plot using bokeh and some financial data

enter image description here

I would like to be able to add an extra line plot on top of this line plot, confined to its own space but still sharing the same date axis as the original figure, similar to the image below (highlighted in yellow)

enter image description here

How can I do this using bokeh? So far I have found some related material on bokeh horizon plots, but everything I've tried with this doesn't really work.

For reference, I am following the sentdex tutorial on youtube where he creates the desired chart using matplotlib.

Upvotes: 1

Views: 1802

Answers (1)

bigreddot
bigreddot

Reputation: 34628

You will have to share ranges, stack the plots, and turn off the x-axis in the top plot, as is done in the OHLC streaming example:

p = figure(plot_height=500, tools="xpan,xwheel_zoom,xbox_zoom,reset", 

p2 = figure(plot_height=250, x_range=p.x_range, y_axis_location="right")

layout = gridplot([[p], [p2]]

enter image description here

Upvotes: 3

Related Questions