pythonholoviewshvplot

Using Holomaps with hvPlot


Is it possible to generate HoloMaps using hvPlot ? I have not found any reference in the documentation.

The goal is to create something like the examples here: http://holoviews.org/reference/containers/bokeh/HoloMap.html#bokeh-gallery-holomap

but using the hvPlot interface


Solution

  • This is definitely possible, the main requirement is that your data is in a tidy format. Once that's the case you can use the groupby keyword to get a DynamicMap or HoloMap which explores the data along that dimension. For example let us adapt the example in the link you pointed to:

    frequencies = [0.5, 0.75, 1.0, 1.25]
    
    def sine_curve(phase, freq):
        xvals = np.arange(100)
        yvals = np.sin(phase+freq*xvals)
        return pd.DataFrame({'x': xvals, 'y': yvals, 'phase': phase, 'freq': freq}, columns=['x', 'y', 'phase', 'freq'])
    
    df = pd.concat([sine_curve(0, f) for f in frequencies])
    
    df.hvplot.line('x', 'y', groupby='freq', dynamic=False)
    

    enter image description here

    Here we create a DataFrame with x and y values for a number of different frequencies, concatenate them and then apply a groupby along the 'freq' column to get a slider for that dimension. To ensure that it returns a HoloMap rather than a DynamicMap we also set dynamic=False.