[Python] Shift data in a holoviews overlay

Discussão em 'Python' iniciado por Stack, Novembro 27, 2024.

  1. Stack

    Stack Membro Participativo

    My code creates an overlay by calculating multiple hv.Curve() together. The issue is, this takes quite some time (in total something like 5000 lines) - around a minute, and its for a webinterface, so waiting that long is just not good.

    But: the grid it creates is always the same, except shifted along the X-Axis (Y is sensor value, X is time, and as the data was acquired at different point in times, the X is flexible between samples).

    Is it possible to create a X=0 based overlay, and then just shift it to new coordinates? I have not found anything like this yet, but I cannot image it being hard to maybe manually set the X coordinates of that overlay, or call a function to set an offset or similar, but I have not been able to find that.

    import numpy as np
    import holoviews as hv
    hv.extension('bokeh')

    points_1 = [(0.1*i, np.sin(0.1*i)) for i in range(100)]
    points_2 = [(0.1*i, np.sin(0.1*i) + np.cos(0.2*i)) for i in range(100)]
    curve_1 = hv.Curve(points_1)
    curve_2 = hv.Curve(points_2)

    overlay = curve_1 * curve_2
    # overlay = overlay + 3 (what to do here to shift the graph 3 units to the right?)
    overlay

    Continue reading...

Compartilhe esta Página