I’m trying to use HoloViews + Datashaeder as part of a python script instead of exclusively in notebooks.
I can create the plot and view it in a notebook but when I follow the example from the FAQ for rendering without the notebook, I receive errors for bokeh:
import holoviews as hv
import numpy as np
from holoviews.operation.datashader import datashade, dynspread
hv.extension('bokeh')
np.random.seed(1)
positions = np.random.multivariate_normal((0,0),[[0.1,0.1], [0.1,1.0]], (1000000,))
points = hv.Points(positions,label="Points")
plot = datashade(points) + dynspread(datashade(points))
renderer = hv.renderer('matplotlib').instance(fig='html')
renderer.save(plot,'testing')
Traceback (most recent call last):
File "holoviews_test.py", line 21, in <module>
renderer.save(plt_out, 'exampleFAQ2')
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/renderer.py", line 465, in save
plot = self_or_cls.get_plot(obj)
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/bokeh/renderer.py", line 112, in get_plot
plot = super(BokehRenderer, self_or_cls).get_plot(obj, renderer)
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/renderer.py", line 177, in get_plot
**plot_opts)
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/bokeh/raster.py", line 20, in __init__
super(RasterPlot, self).__init__(*args, **kwargs)
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/bokeh/element.py", line 180, in __init__
self.callbacks = self._construct_callbacks()
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/bokeh/element.py", line 216, in _construct_callbacks
cbs.append(cb(self, cb_streams, source))
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/bokeh/callbacks.py", line 54, in __init__
self.comm = self._comm_type(plot, on_msg=self.on_msg)
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/comms.py", line 210, in __init__
self.manager = get_ipython().kernel.comm_manager
AttributeError: 'NoneType' object has no attribute 'kernel'
and when I try to make the same plot with matplotlib:
hv.extension('matplotlib')
renderer = hv.renderer('matplotlib').instance(fig='png')
renderer.save(plot,'testing')
Traceback (most recent call last):
File "holoviews_test.py", line 21, in <module>
renderer.save(plt_out, 'exampleFAQ2') #, style=dict(Image=
{'cmap':'jet'}))
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/renderer.py", line 465, in save
plot = self_or_cls.get_plot(obj)
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/renderer.py", line 178, in get_plot
plot.update(0)
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/mpl/plot.py", line 244, in update
return self.initialize_plot()
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/mpl/plot.py", line 43, in wrapper
return f(self, *args, **kwargs)
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/mpl/plot.py", line 1090, in
initialize_plot
hspace=self.hspace*self.fig_scale)
File "/anaconda2/lib/python2.7/site-
packages/holoviews/plotting/mpl/util.py", line 113, in fix_aspect
bbox = ax.get_tightbbox(fig.canvas.renderer)
AttributeError: 'FigureCanvasMac' object has no attribute 'renderer'
The rendering example code works for basic holoviews Elements but fails once I add the multiple datashader methods. Any help would be appreciated!