holoviz-topics / neuro

HoloViz+Bokeh for Neuroscience
BSD 3-Clause "New" or "Revised" License
17 stars 5 forks source link

add predefined selection hooks for rangetoollink #57

Closed droumis closed 1 year ago

droumis commented 1 year ago

Approach:

# ...

# create a hook to set a predefined selection of RangeToolLink
max_ch_disp = 10
max_t_disp = 5
range_opts = []

def xrange_hook(plot, element):
    plot.handles['x_range'].end = max_t_disp

def yrange_hook(plot, element):
    plot.handles['y_range'].end = np.max(data[max_ch_disp-1,:] + ((max_ch_disp-1) * offset))

if time.max() > max_t_disp:
    range_opts.append(xrange_hook)

if len(channel_curves) > max_ch_disp:
    range_opts.append(yrange_hook)

# Create an overlay of curves
eeg_viewer = hv.Overlay(channel_curves, kdims="Channel").opts(
    width=800, height=600, padding=0, xlabel="Time (s)", ylabel="Channel",
    yticks=yticks, show_legend=False, hooks=range_opts,)

# ...

image