Let’s say I have a 3D array that I want to display different slices of (that part is fairly standard):
import numpy as np import xarray as xr import holoviews as hv hv.extension('bokeh') ls = np.linspace(-5, 5, 100) xx, yy,zz = np.meshgrid(ls, ls, ls) img_np = np.sin(xx) * np.cos(yy+zz) img_xr = xr.DataArray(data=img_np, dims=['a','b','c'], coords=[ls, ls, ls]) def plot_c_slice(c): return hv.Image(img_xr.sel(c=c)) dmap = hv.DynamicMap(plot_c_slice, kdims=['c']).redim.values(c=ls) dmap
That example (in the links above) is for the simple case of a ‘static’ image (2D array), yet as I’m viewing different slices I need to get the dynamic parameter (‘c’ in the example above) into cross_hair_info function. E.g., let’s say I’m interested in text displaying mean(a,b,c), where a,b are the 2D spatial coordinates of the image, and c is the slice.
How would I achieve that?
I have to admit that although I’ve looked at some of the references related to this topic, I’m feeling a bit lost…