Search code examples
python-3.xholoviews

Dimension containers when plotting Holoviews Curve and spread overlay in Holomap


With the script below I expected to get a dropdown menu for changing the slope. i.e only showing one of the plots, not all three.

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

slope = [1, 5, 10]

def curve(slope):
    x = np.linspace(1,10)
    y = slope*0.5+x
    err = x*0.2
    return hv.Curve((x, y)) * hv.Spread((x,y,err))


curve_dict = {r:curve(r) for r in slope}

kdims = hv.Dimension(("slope", "slope"))

hmap = hv.HoloMap(curve_dict, kdims=kdims).overlay()
hmap

This return the following plot:

enter image description here

What am I missing here? I expected a dropdown menu, not all three graphs showing up.


Solution

  • You turned your holomap into an overlay() which basically means putting the plots on top of eachother.

    When you remove the .overlay() you get the slider to select your plot:

    hmap = hv.HoloMap(curve_dict, kdims=kdims)