Reputation: 45
I want to be able to programmatically change the range of a DynamicMap based on a variable name for the kdim. For example:
frequencies = [0.5, 0.75, 1.0, 1.25]
def sine_curve(phase, freq):
xvals = [0.1* i for i in range(100)]
return hv.Curve((xvals, [np.sin(phase+freq*x) for x in xvals]))
dmap = hv.DynamicMap(sine_curve, kdims=['phase', 'frequency'])
dmap.redim.range(phase=(0.5,1)).redim.range(frequency=(0.5,1.25))
I want to do something like this:
label = 'frequency'
dmap = hv.DynamicMap(sine_curve, kdims=['phase', label])
dmap.redim.range(phase=(0.5,1)).redim.range(label=(0.5,1.25))
Is there a proper way to do this?
Upvotes: 1
Views: 874
Reputation: 4080
To programmatically define keyword arguments in Python you can simply create a dictionary and unpack it, e.g. in your example that would look like this:
dmap.redim.range(**{'phase': (0.5, 1), label: (0.5, 1.25)})
Upvotes: 3