In [ ]:
import numpy as np
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')
In [ ]:
opts.defaults(opts.Curve(width=100))
# Create two images
x,y = np.meshgrid(np.linspace(-5,5,101), np.linspace(5,-5,101))
img1 = hv.Image(np.sin(x**2+y**2))
img2 = hv.Image(np.sin(x**2+y**3))
# Declare PointerX and dynamic VLine
posx = hv.streams.PointerX()
vline = hv.DynamicMap(lambda x: hv.VLine(x or -100), streams=[posx])
# Declare cross-sections at PointerX location
crosssection1 = hv.DynamicMap(lambda x: img1.sample(x=x if x else 0), streams=[posx])
crosssection2 = hv.DynamicMap(lambda x: img2.sample(x=x if x else 0), streams=[posx])
# Combine images, vline and cross-sections
((img1 * vline) << crosssection1) + ((img2 * vline) << crosssection2)