Simplest way to show 3D numpy cube

The syntax for creating multi-dimensional cubes in HoloViews is something like this:

# Declare coordinate arrays (i.e. kdims)
xs = np.arange(10)
ys = np.arange(20)
time = np.arange(30)

# Declare value array (i.e. the vdim)
values = np.random.rand(20, 10, 30)
hv.Dataset((time, xs, ys, values), ['time', 'x', 'y'], ['value'])

i.e. you provide a tuple of the coordinate arrays along with the value array(s). You could then group by the ‘time’ or ‘z’ dimension. Not also that if you remember this HoloViews can generate an xarray object for you:

ds = hv.Dataset((time, xs, ys, values), ['time', 'x', 'y'], ['value'], datatype=['xarray'])
ds.data # This is now an xr.Dataset

Hope that helps.

1 Like