Rasterizing takes long time after resetting plot

Hi,

I am wondering if I am doing something wrong or not. I am trying to plot multiple large timeseries in a row. I use rasterize for that. Everything works fine, but as soon as I press the reset button from the tools, it is taking more time to update when zooming in/out.

Here is the code I use to build the curves:

def plot_ts(timeseries: list):
    # create times
    times = []
    for ts in timeseries:
        times.append(np.arange(len(ts)))
    # create fake channel names
    ch_names = [f"ch_{i}" for i in range(len(timeseries))]

    # generate curve for each ts
    curve = None
    for i, ch in enumerate(ch_names):
        if curve is None:
            curve = rasterize(
                hv.Curve(
                    (
                        times[i],
                        timeseries[i],
                    ),
                ),
                # precompute=True,
            ).opts(
                ylabel=f"{ch}",
            )
        else:
            curve += rasterize(
                hv.Curve(
                    (
                        times[i],
                        timeseries[i],
                    ),
                ),
                # precompute=True,
            ).opts(
                ylabel=f"{ch}",
            )
    return curve

Then I run it with fake data:

    timeseries = [np.random.rand(50000) + np.random.randint(-1, 1) for _ in range(20)]
    curves = plot_ts(timeseries, share_y=False)
    curves.cols(1)
    panel = pn.panel(curves)
    server = pn.serve(panel)

Behavior is very nice until I reset the plot:
holoviews_slow_after_reset

Is it expected behavior from the “reset” button or am I doing something wrong ?
Any help would be much appreciated!

Resetting the plot shouldn’t change the speed, or at least it shouldn’t get slower than the original setting. Plots can be much faster when zoomed in, since only a portion of the original dataset needs rendering, but resetting should just go back to the original speed, not a slower one. I can’t quite be sure from that gif whether the speed is actually different, since different ranges are being selected, but it does look slower. We’d probably have to capture these events programmatically to compare to be sure.

Thank you. I simplified my the code above + the animation. Resetting seems to have an impact on rasterization, but I understand that it shouldn’t. Here is the output with the clean code:
holoviews_slow_after_reset_2

It is worth mentioning that when plotting only 12 timeseries (instead of 20 here), the delay decreases drastically.