I am trying to annotate some time series data with different occurrences in time. To do this I have created an overlay of curves and a holoviews.element.raster.Image (see code below).
As per here and here I know that the axis should have the same units and label for holoviews to automatically link them. I have tried this in the example code below, but the plots are still not linked.
import xarray as xr
import numpy as np
# creaty dummy data
t = np.linspace(-10,10,50)
dates = pd.to_datetime(np.linspace(pd.Timestamp('2017-01-01').value, pd.Timestamp('2018-01-01').value, 200))
data = np.random.rand(50,200)
xrData = xr.DataArray(data, dims=['time','dates'], coords={'time':t, 'dates':dates})
dataplot = xrData.hvplot(width=1000)
# create annotations
line1 = hv.Curve([
[pd.Timestamp('2017-03-01'), 0],
[pd.Timestamp('2017-06-01'), 0]], ('x','dates'), label='eventA').opts(line_width=20, color='red')
line2 = hv.Curve([
[pd.Timestamp('2017-08-01'), 0],
[pd.Timestamp('2017-10-01'), 0]], ('x','dates'), label='eventA').opts(line_width=20, color='red')
line3 = hv.Curve([
[pd.Timestamp('2017-11-01'), 0],
[pd.Timestamp('2017-12-01'), 0]], ('x','dates'), label='eventB').opts(line_width=20, color='blue')
annotations = line1 * line2 * line3
annotations.opts(width=1000,height=150, legend_cols=2, yaxis=None)
annotations = annotations.redim(y=hv.Dimension('y', range=(-0.25, 1)))
annotated_data = (annotations + dataplot).cols(1)
annotated_data