Is there a way to adjust the selection range in the RangeToolLink?
By default, the entire area of the plot is selected, which can then be adjusted and/or moved accordingly.
(From https://www.holoviews.org/gallery/demos/bokeh/timeseries_range_tool.html)
In Holoviews it is possible to set the underling properties of the figure using a hook.
In the example below there are two different hooks used for the upper and lower figure.
import pandas as pd
import holoviews as hv
from holoviews import opts
from holoviews.plotting.links import RangeToolLink
hv.extension('bokeh')
from bokeh.sampledata.stocks import AAPL
aapl_df = pd.DataFrame(AAPL['close'], columns=['close'], index=pd.to_datetime(AAPL['date']))
aapl_df.index.name = 'Date'
aapl_curve = hv.Curve(aapl_df, 'Date', ('close', 'Price ($)'))
def hook(plot, element):
plot.handles['x_range'].start = pd.to_datetime('2006')
plot.handles['x_range'].end = pd.to_datetime('2008')
tgt = aapl_curve.relabel('AAPL close price').opts(width=800, labelled=['y'], toolbar='disable').opts(hooks=[hook])
def hook(plot, element):
plot.handles['x_range'].start = pd.to_datetime('2000')
plot.handles['x_range'].end = pd.to_datetime('2014')
src = aapl_curve.opts(width=800, height=100, yaxis=None, default_tools=[]).opts(hooks=[hook])
RangeToolLink(src, tgt)
layout = (tgt + src).cols(1)
layout.opts(opts.Layout(shared_axes=False, merge_tools=False))
The result is very similar to the range_tool example of the bokeh library.