Distinct HoloViews plots sharing the same data range when embedded in Panel dashboards

Dear all,

Has anyone already faced a problem of two holoviews plots unwillingly sharing the same data ranges? I have a panel dashboard that calls two distinct plots and present them side by side and each one of them inside a WidgetBox. Each plot is generated as in the script below and apparently have nothing in common (the plot_opts are local variables!). Even though, in the final result they share the data range (the one in the right takes the data range of the one in the left).

Is this an issue or just me screwing things up?

import numpy as np
import holoviews as hv 
from holoviews import opts
from holoviews import streams
from holoviews.operation.datashader import regrid

def getPlanePlot(plane, cmap, origin_file_type):

    if origin_file_type == 'sep_gathers' or origin_file_type == 'segy_gathers':
        clip = 99
        half_range = (plane.max() - plane.min())/2
        m_clip = (half_range / 100.) * clip
        vmin = -half_range + m_clip
        vmax = -vmin        

    elif origin_file_type == 'velocity_model':
        clip=np.percentile(plane, 99.9)
        vmin = clip
        vmax = -vmin

    plane = plane[::-1,:]
    bounds=(0, 0, plane.shape[1], plane.shape[0])
    plot_opts = {
                'height': height, 
                'width': width, 
                'colorbar': True, 
                'clim':(vmin, vmax), 
                'xlabel': '',
                'ylabel': '',
                'xlim': (0, plane.shape[1]),
                'ylim': (0, plane.shape[0]),
                'xaxis': 'top',
                'invert_yaxis': True,
    style_opts = {'cmap': cmap}
    img = hv.Image(plane, bounds=bounds).opts(plot=plot_opts, style=style_opts)
    return regrid(img, upsample=True, interpolation='bilinear', precompute=True)

def PlotTrace(plane, line_id, wiggle, wiggle_limits):


    vmin = round(wiggle_limits[0])
    vmax = round(wiggle_limits[1])
    trace = np.round(plane[line_id-1][vmin:vmax], 5)
    x = np.arange(vmin, vmax)
    x_interp = np.linspace(vmin, vmax, 20*len(x))
    trace_interp = np.interp(x_interp, x, trace)       
    lim = 1.05*max((abs(trace.min()), trace.max()))

    if wiggle == 'Positive':
        w = np.array([i if i > 0 else 0 for i in trace_interp])
    elif wiggle == 'Negative':
        w = np.array([i if i < 0 else 0 for i in trace_interp])
        w = np.zeros(len(trace_interp))

    plot_opts_trace = {'height': aspect, 
                       'width': aspect, 
                       'xlabel': '',
                       'ylabel': '',
                       'xlim': (vmin, vmax),
                       'ylim': (-lim, lim),
                       'xaxis': 'top',
                       'invert_yaxis': True,
                       'invert_axes': True, 

    style_opts_curve = {'color': 'k'}
    style_opts_area = {'fill_color': 'k'}

    return hv.Area((x_interp, w)).opts(plot=plot_opts_trace, style=style_opts_area) * hv.Curve((x_interp, trace_interp)).opts(plot=plot_opts_trace, style=style_opts_curve)

It looks like your dimension names match (for both data structures you use the default assignments). You could use more verbose data structures like pandas dataframes such that variable names are propagated into holoviews, or manually assigning variable names.

Thank you for the hint. Indeed it works but I’m still wondering why there is a “data leaking” from one plot to the other since the defaults parameters should have been local variables within each function. It didn’t happen in panel 0.7 and started after I upgraded it to 0.8 version. Interesting…

Yeah, I assume this is part of the general holoviz magic where stuff just works ™. I haven’t tried across different panels but you could experiment with manual linking/unlinking using holoviews’ DataLinks.

See discussion at https://github.com/holoviz/panel/issues/798 and links in that issue for more information. (Via @ahuang11 and gitter)