I am trying to use HoloViews hv.archive function in Jupyter Lab, but no archive is generated when I run the code.
When I run:
hv.archive.auto()
df.testplot() # create holoviews plot
hv.archive.contents()
hv.archive.export()
I get this: Javascript Error: IPython is not defined
When running in Jupyter Notebook I don't get the error and an archive folder is created, but I still can't generate the archived plots.
Any way forward would be much appreciated. Thanks!
Currently hv.archive() doesn't work with Jupyter Lab, but it should work with Jupyter Notebook though.
See this github issue:
https://github.com/holoviz/holoviews/issues/3570
If I run the code below in Jupyter Notebook, it works for me.
Note: run the code below not all at once, but just part by part.
Otherwise I think the filesystem can't keep up and you get an error.
import holoviews as hv
# you can also choose the bokeh backend, but
# no .svg image will be saved
hv.extension('matplotlib')
# start archiving automatically
hv.archive.auto()
# create a simple plot
hv.Curve(range(0,3))
# check contents of current archive
hv.archive.contents()
# export archive to disk
hv.archive.export()
# check status of export
hv.archive.last_export_status()
# recreate simple plot from archive
import os
from holoviews.core.io import Unpickler
path = os.path.join(hv.archive.notebook_name, 'Curve.hvz')
if os.path.isfile(path):
obj = Unpickler.load(open(path,"rb"))
print(obj)
obj
This is what my archive looks like when exported to disk:
More info on archiving can be found here:
http://holoviews.org/user_guide/Exporting_and_Archiving.html