How can one make bokeh use zoom only on one axis and automatically scale objects, so they take exactly the space given and add some padding on extreme points off zoom-able axis parallels, while rendering empty space out of scope?
In other words (or "madskills" to be exact): Example plot.
This is most widely used for stocks plotting, so consider I want to copy zoom behavior of https://www.tradingview.com/chart/?symbol=FX:XAUUSD with Bokeh. Thank you in advance.
Zoom on X axis only by using 'xwheel_zoom' tool:
from bokeh.plotting import figure
fig = figure(tools='xwheel_zoom', active_scroll='xwheel_zoom')
Auto-scale the other (Y) axis by invoking a custom JavaScript event whenever the first axis changes. In this event, you scan through the visible data and amend the axis range. Like in the following gist example: https://gist.github.com/kernc/719918ada11298168efd956afc1a04a8
As of Bokeh 0.12.7
there is nothing built-in that will do this. Auto-ranging is always over the entire data set. There is no option to have auto ranging happen only over a subset of the data that is currently visible according to the extents of some other dimension.
It's possible to extend Bokeh, so it it conceivable that you could write a custom extension subclass of DataRange1d
but it would not be a completely trivial matter:
http://docs.bokeh.org/en/latest/docs/user_guide/extensions.html
However, it seems like a reasonable feature request, so I'd encourage you to file a GitHub issue to discuss adding this capability directly to the core library:
https://github.com/bokeh/bokeh/issues
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With