Xlim, NdOverlay and DynamicMap interaction

The solution is to add “.opts(‘Spikes’, framewise=True, axiswise=True))” to the DynamicMap:

class test(param.Parameterized):
    start=param.Number(5, bounds=(1.0, 100.0))
    stop=param.Number(10, bounds=(1.0, 100.0))
    
    @param.depends("start", "stop")
    def plot(self):
        overlay = hv.NdOverlay({i: hv.Spikes(np.random.randint(0, 100, 10), kdims='Time').opts(position=0.1*i)
                           for i in range(10)}).opts(yticks=[((i+1)*0.1-0.05, i) for i in range(10)])
        out = overlay.opts(opts.Spikes(spike_length=0.1),opts.NdOverlay(shared_axes=True, height=200,show_legend=False,xlim=(self.start,self.stop)))
        return out

          
t = test(start=2, stop=9)
pn.Column(t.param, hv.DynamicMap(t.plot).opts('Spikes', framewise=True, axiswise=True))

Thanks to How to update limits for DynamicMap overlays? - #2 by ahuang11

1 Like