Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Holoviews interactive plot of gridded data with slider on top

This code creates an interactive plot with Holoviews:

import numpy as np
import xarray as xr
import holoviews as hv
hv.extension('bokeh')

# Create sample data
x = np.linspace(-10, 10, 10)
y = np.linspace(-10, 10, 10)
time = np.arange(0, 10, 1)
data = np.random.rand(len(time), len(x), len(y))

# Create xarray DataFrame
ds = xr.DataArray(data, coords=[time, x, y], dims=['time', 'x', 'y'], name='data').to_dataset()

# Create Holoviews Dataset
hv_ds = gv.Dataset(ds, kdims=['time', 'y', 'x'], vdims=['data'])

#plot with slider
hv_ds.to(gv.Image, ['x', 'y'])

It creates a gridded plot of the data with a slider that moves through the time dimension. By default, the slider is placed on the right.

How can I move the slider so it is on top of the plot?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

For full layout control, you can use Panel directly, but for simply selecting a different location you can set hv.output(widget_location=<option>) where the valid <option>s are:

['left', 'bottom', 'right', 'top', 'top_left', 'top_right',
 'bottom_left', 'bottom_right', 'left_top', 'left_bottom',
 'right_top', 'right_bottom']
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading