Search code examples
pythonbokeh

In a bokeh plot with two seperate y-axes, how can I zoom on y-axis and keep the second fixed?


I have created a bokeh plot with two lines in one plot. I have also created two separate y-axes making use of extra_y_ranges and Range1d.

I can set the initial range of each y-axis. When I use the zoom wheel, it affects both y-axes but I want to only change one of them and not both.

I even tried setting separate renderers, as follows but still failed to achieve the goal.

plot1.y_range.renderers=[line1]
plot1.extra_y_ranges.renderers=[line2]

Can anyone help me get a separate y-axis zoom level? i.e. only zoom in one line while keeping the other one constant. Thanks.

P.S. My code uses add_periodic_callback to update the plot in real-time based on a DB if that makes any difference.


Solution

  • The link mentioned by @mosc9575 works perfectly. Thanks.