Extract range of zoomed plot

Hello,

Is there a way to extract information about zoomed area in hv.Image?

I need this for the following reason:

  1. I have two plots. One of them represents raw data of some kind, whereas the other shows the result of some complex computation on that data. Those plots’s axes represent different quantities, so those axes are not shared.
  2. When a user zooms in the raw data plot, I want the second plot to recompute using only the data that is zoomed on the raw data plot.

If I there was a way to get zoomed data range, I could make a second plot a DynamicMap that just reevaluates every time the user zooms in the first figure using the zoom range to filter my data.

Thanks :slight_smile:

import param
import holoviews as hv
import numpy as np
import panel as pn
hv.extension('bokeh')

data = np.random.rand(10,10)
img = hv.Image(data)
rxy = hv.streams.RangeXY(source=img, x_range=(-0.5, 0.5), y_range=(-0.5,0.5))
(img + hv.DynamicMap(lambda x_range, y_range: hv.Curve(((0,1),x_range)), streams=[rxy]).opts(ylim=(-0.5,0.5)) + hv.DynamicMap(lambda x_range, y_range: hv.Curve(((0,1),y_range)), streams=[rxy]).opts(ylim=(-0.5,0.5))).opts(shared_axes=False)

2 Likes