I am trying to construct something following the example at: https://examples.pyviz.org/datashader_dashboard/dashboard.html
In particular the dashboard I am trying to create (semi-working version here: https://github.com/dhruvbalwada/glider-panel-demo/blob/main/glider_vertical_section.ipynb) has a lot of elements being plotted, and I would like to avoid having to replot everything every time I change some widget. The dashboard example talks exactly about this. However, I am having some trouble if I try to set some options inside the final function (view/viewable) that plots things. The dashboard example seems to do exactly that, but I am not sure why it is not working for me (and I am not able to get the dashboard example to run on my computer to check whether the example still works with the latest versions).
Here is a minimal example:
import xarray as xr import hvplot.xarray # noqa import panel as pn pn.extension() import param import holoviews as hv from holoviews import opts from holoviews import streams air_ds = xr.tutorial.open_dataset('air_temperature').load() air = air_ds.air class LatSliderPlot(param.Parameterized): lat_slider = param.Range(label='Lat', bounds=(200, 330), default=(200, 220)) def plot_image(self): image = hv.Image( (air.lon, air.lat, air.isel(time=0)) ) return image def viewable(self): img = hv.DynamicMap(self.plot_image) img.opts(opts.Image(xlim=self.lat_slider)) return img test = LatSliderPlot() pn.Column(test.param, test.viewable()) # this create a non-responsive plot # but is the suggested way in the dashboard example. pn.Column(test.param, test.viewable) # this create a responsive plot, #but replots the image everytime.
In this toy example, I would like to be able to be change the xlim of the image without having to replot it every single time.
Could someone please help me identify what I am doing wrong? Or suggest some other examples to look at?