Multiple independent Holoviews DynamicMap


I want to create an application with multiple independent DynamicMap, i.e. the axes of the plots should not be linked.

If I do this (dummy example):

x = np.linspace(0, 2*np.pi)
dmap1 = hv.DynamicMap(lambda a: hv.Curve({"x":x, "y":a* np.cos(x)}), kdims='a').redim.range(a=(0,5))
dmap2 = hv.DynamicMap(lambda a: hv.Curve({"x":x, "y": a* np.sin(x)}), kdims='a').redim.range(a=(0,5))

pn.Column(dmap1, dmap2)

, I do get two DynamicMaps, but their axes will be linked, which I don’t want:

The only post that I found talking about this problem was this stack overflow question: python - How to create a Holoviews app with multiple independent DynamicMap plots? - Stack Overflow. However, the solution presented there is obsolete, because newer versions of Holoviews use Panel’s widgets.

I am using Bokeh as a backend.

Thanks a lot for the help

one way would be to use different dimension names
using the same label, e.g.,

x = np.linspace(0, 2*np.pi)
dmap1 = hv.DynamicMap(lambda a1: hv.Curve({"x":x, "y":a1* np.cos(x)}), kdims=hv.Dimension('a1', label='a')).redim.range(a1=(0,5))
dmap2 = hv.DynamicMap(lambda a2: hv.Curve({"x":x, "y":a2* np.sin(x)}), kdims=hv.Dimension('a2', label='a')).redim.range(a2=(0,5))

pn.Column(dmap1, dmap2)

I have tried this, but it really doesn’t change much. The axes are still linked.

rename all the axes:

def func(a,x,f,i):
    xd = hv.Dimension(f'a{i}', label='a')
    yd = hv.Dimension(f'b{i}', label='b')
    return hv.Curve( (x, a*f(x)), kdims=xd, vdims=yd )
x = np.linspace(0, 2*np.pi)

    hv.DynamicMap( lambda a1: func( a1, x, np.cos, 1), kdims="a").redim.range(a=(0,5)),
    hv.DynamicMap( lambda a2: func( a2, x, np.sin, 2), kdims="a").redim.range(a=(0,5))

This works, thanks :slight_smile: