# Using tap stream to update curve plot xlim

I am trying to build a simple layout visualization that includes 2 plots - a heatmap and a curve
each plot has its own data source and I would like to use the coordinates from the heatmap to update the curve plot.
my (simplified) current code looks like this:

``````import holoviews as hv

# x, y, xy are NumPy arrays
tiles = [(x[j], y[i], xy[i, j]) for i in range(len(y)) for j in range(len(x))]   # creating a grid like list
heatmap = hv.HeatMap(tiles)

# Declare Tap stream with heatmap as the source and initial values
posxy = hv.streams.Tap(source=heatmap, x=x[0], y=0)

# create the curve plot, t and v are NumPy arrays with 1 dimention
curve = hv.Curve((t, v))

# Define function to view the relevant time series based on tap location
def tap_curve(x, y):
curve.opts(xlim=(x, x + 10))
return curve

# Connect the Tap stream to the tap_ts callback
tap_dmap = hv.DynamicMap(tap_ts, streams=[posxy])
layout = heatmap + tap_dmap
``````

the resulting figure doesnâ€™t update itself when I tap the heatmap but does visualize the curve figure with the initial values.
the figure looks like this (there is a lot of code I ommited to simplify my intentions)

how should I define the â€śtap_curveâ€ť function to properly update my curve plot? or the problem is not even in this function? I tried different things but nothing seemed to work.
any help would be appreciated

found the solution:

``````import holoviews as hv

# x, y, xy are NumPy arrays
tiles = [(x[j], y[i], xy[i, j]) for i in range(len(y)) for j in range(len(x))]   # creating a grid like list
heatmap = hv.HeatMap(tiles)

# Declare Tap stream with heatmap as the source and initial values
posxy = hv.streams.Tap(source=heatmap, x=x[0], y=0)

# Define function to view the relevant time series based on tap location
def tap_curve(x, y):
curve = hv.Curve((t, v))
curve = curve.opts(xlim=(x, x + 10), framewise=True)
return curve

# Connect the Tap stream to the tap_ts callback
tap_dmap = hv.DynamicMap(tap_ts, streams=[posxy])
layout = heatmap + tap_dmap
``````

apparently the â€śframewise=Trueâ€ť is critical for proper updating, Iâ€™m not sure why and what exactly it does but it works as expected like thisâ€¦

2 Likes