5

With HoloViews/Bokeh Renderer (Holoviews = 1.11.2 / Bokeh 1.0.4 via current anaconda on Windows), I want to create a layout which consist of a scatter plot and RGB image. The scatter plot shows values of light-dark contrast in a movie. The RGB image shows a screenshot coming from the movie. The goal is to be able to click on a point in the scatter plot and the image from that time stamp in the movie is loaded.

enter image description here

Everything works well as long as the scatter plot is not more than a hv.Points Element associated with a tap tool and a selection1D stream.

%%opts Points [width=1108, size_index=2, tools=['hover', 'tap'], toolbar='left'] (alpha=0.2)
%%opts RGB [toolbar='left']

scatter = hv.Points(il_colful, kdims=['frame', 'bin'], vdims=['pixels', 'time'])

tap_point = streams.Selection1D(source=scatter)

def frmimg(index):
    if index:
        frame = il_colful.iloc[index[0]]['frame']
        url = './il_divo/frames/576p30/il_divo_' + '{0:05}'.format(frame) + '.png'
    else:
        url = './il_divo/frames/576p30/il_divo_00100.png'
    return hv.RGB.load_image(url).options(height=480, width=1108, xaxis=None, yaxis=None)

(hv.DynamicMap(frmimg,
     streams=[tap_point])
     + scatter).cols(1)

However, when I turn the scatter plot into a DynamicMap (because I want offer interactive modification for some of the scatter plots parameters) I can not use the tap tool on the scatter plot any longer, I do not get any crosshair symbol on the scatter plot and I am not able to make any selections).

points = hv.Points(il_colful1, kdims=['frame', 'bin'])
selected = streams.Selection1D(source=points)

def scatter(div=5000, thrsh=0, alpha=0.1):
    global points
    il_colful1['scaler'] = (il_colful1['pixels'] / div).round(0).astype(int)
    il_colful_lim1 = il_colful1[il_colful1['pixels'] > thrsh]
    points = hv.Points(il_colful_lim1, kdims=['frame', 'bin'], vdims=['pixels', 'time', 'scaler'], label='Il Divo').opts(tools=['tap'], width=1000, color='blue', size_index='scaler', fill_alpha=alpha, line_alpha=alpha)
    return points

def img(index):
    if index:
        frame = il_colful1.iloc[index[0]]['frame']
        url = './il_divo/frames/576p30/il_divo_' + '{0:05}'.format(frame) + '.png'
    else:
        url = './il_divo/frames/576p30/il_divo_00100.png'
    return hv.RGB.load_image(url).options(height=433, width=1000, xaxis=None, yaxis=None)

il_divo_sct = hv.DynamicMap(scatter, kdims=['div', 'thrsh', 'alpha']).redim.range(div=(500, 15000), thrsh=(0, 50000), alpha=(0.01, 1.0)).opts(tools=['tap'])
screenshot = hv.DynamicMap(img, streams=[selected])

(screenshot + il_divo_sct).cols(1)

Is it not possible to use the tap tool on DynamicMaps/Layers within a DynamicMap or do I miss something

Cutú Chiqueño
  • 855
  • 1
  • 10
  • 24

0 Answers0