I am trying to link a RangeSlider to the xlim of an image element. Since xlim is a parameter, it seems to me like using .link
should allow me to link the slider’s value
to element’s xlim
(based on the docs here: https://panel.holoviz.org/user_guide/Links.html). However, my attempt does not seem to work.
It seems like the parameters of the elements are no exposed? Is there another way to do this?
This an attempt to solve the question : Two way link between a widget and a linked stream.
Here is the code:
import xarray as xr
import hvplot.xarray # noqa
import panel as pn
from holoviews import streams
import holoviews as hv
pn.extension()
air_ds = xr.tutorial.open_dataset('air_temperature').load()
air = air_ds.air
# setup an image
image = air_ds.air.sel(time='2013-01-01T00:00:00', method='nearest').hvplot()
# setup a slider
Xslide = pn.widgets.RangeSlider(start=float(air_ds.lon.min().data),
end=float(air_ds.lon.max().data),
step=0.1)
Xslide.link(image, value='xlim')
pn.Column(Xslide, image) #this generates a slider and image, but they are not linked.
P.S. : I think I do understand how link works, because I could make this simple set of connected widgets:
slide1 = pn.widgets.RangeSlider(start=0,
end=1,
step=0.1)
slide2 = pn.widgets.RangeSlider(start=0,
end=1,
step=0.1)
slide1.link(slide2, value='value', bidirectional=True)
pn.Column(slide1, slide2)
Now just want to do the same, but connect to the xlim of a plot instead of second slider widget.