I have a number of functions that I find useful enough to consider packaging them in some way. E.g.,
def spikes(data, y_base=0, dims=["Time", "x"], label="Signal", curve=True):
if isinstance(data, tuple):
t,s=data
else:
t=np.arange(0,len(data), 1)
s=data
vlines = [ np.array( [[t[i], y_base], [t[i], s[i]]]) for i in range(len(s)) ]
hs = hv.Path( vlines, kdims=dims, label=label ).opts( show_legend=True, muted_alpha=0., color='black')
if curve: hs = hs * hv.Curve((t,s), dims[0], dims[1], label=label).opts(line_width=0.8)
return hs
def cx_spikes(data, dims=["Time", "x"], y_base=0, curve=False):
if isinstance(data, tuple):
t,s=data
else:
t=np.arange(0,len(data), 1)
s=data
h = hv.Overlay([
*spikes((t, np.real(s)), y_base=y_base, label='real', curve=True).opts( "Path", color='blue'),
*spikes((t, np.imag(s)), y_base=y_base, label='imag', curve=True).opts( "Path", color='red')])
return h
I am looking for recommendations for the best way to do so?
- how to modify the code to fit the Holoviews implementation style?
- how to set this up to work with either bokeh or matplotlib
- where and how to install it for easy access?
- whatever else I am missing