Search code examples
python-3.xbokehholoviews

When saving Holoviews DynamicMap using hv.save() only three frames are rendered


I am wanting to export my HoloViews DynamicMap as it is viewed in a Jupyter notebook, but it only exports three frames in the resulting HTML file. I created the following sample code to demonstrate the problem I am experiencing, which is a simplified version of the example at https://holoviews.org/reference/containers/bokeh/DynamicMap.html

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

def sine_curve(phase, freq=0.5):
    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']).redim.range(phase=(0.,1.))

dmap # to render interactively in Jupyter notebook

hv.save(dmap, 'test.html')

If I run this in a Jupyter notebook, the slider will render 11 different phase diagrams (every phase shift of 0.1). However, once I save it as test.html, it will only render three total phase diagrams (0, 0.5, 1). Is there a way to render all the frames in the HTML file?


Solution

  • Solution was to replace .redim.range(phase=(0.,1.)) with .redim.values(phase=full_set_of_values) where full_set_of_values = [0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.]. See https://github.com/holoviz/holoviews/issues/5273 for more info.