我无法理解为什么无法使用散景渲染以下全息视图对象结构:
:NdLayout [dim1]
:HoloMap [dim2]
:Overlay
.Scatter.I :Scatter [a] (b)
.Scatter.II :Scatter [a] (b,c)
如果我尝试使用 holoviews.save 将其导出到静态 HTML 文件,则会收到以下错误:
Traceback (most recent call last):
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/bokeh/element.py", line 1268, in _init_glyphs
style = self._apply_transforms(element, data, ranges, style)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/bokeh/element.py", line 1076, in _apply_transforms
group=group, **kwargs)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/bokeh/element.py", line 1782, in _get_colormapper
cmapper = colormapper(palette=palette, **opts)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/bokeh/models/mappers.py", line 141, in __init__
super().__init__(**kwargs)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/bokeh/models/mappers.py", line 91, in __init__
super().__init__(**kwargs)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/bokeh/model.py", line 234, in __init__
super().__init__(**kwargs)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/bokeh/core/has_props.py", line 247, in __init__
setattr(self, name, value)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/bokeh/core/has_props.py", line 274, in __setattr__
super().__setattr__(name, value)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/bokeh/core/property/descriptors.py", line 539, in __set__
self._internal_set(obj, value, setter=setter)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/bokeh/core/property/descriptors.py", line 760, in _internal_set
value = self.property.prepare_value(obj, self.name, value)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/bokeh/core/property/bases.py", line 331, in prepare_value
raise e
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/bokeh/core/property/bases.py", line 324, in prepare_value
self.validate(value)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/bokeh/core/property/either.py", line 109, in validate
raise ValueError(msg)
ValueError: expected an element of either Seq(String), Seq(Tuple(String, String)) or Seq(Tuple(String, String, String)), got [nan]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<ipython-input-109-fac255f6253f>", line 1, in <module>
hv.save(data_shuffle_overlap_z, saveDir_plot/f'layout_z_overlap.png')
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/util/__init__.py", line 799, in save
return renderer_obj.save(obj, filename, fmt=fmt, resources=resources)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/renderer.py", line 547, in save
plot, fmt = self_or_cls._validate(obj, fmt)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/renderer.py", line 287, in _validate
plot = self.get_plot(obj, renderer=self, **kwargs)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/bokeh/renderer.py", line 73, in get_plot
plot = super(BokehRenderer, self_or_cls).get_plot(obj, doc, renderer, **kwargs)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/renderer.py", line 232, in get_plot
plot.update(init_key)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/plot.py", line 879, in update
item = self.__getitem__(key)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/plot.py", line 437, in __getitem__
if not self.drawn: self.handles['fig'] = self.initialize_plot()
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/bokeh/plot.py", line 909, in initialize_plot
subplots = subplot.initialize_plot(ranges=ranges, plots=shared_plots)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/bokeh/plot.py", line 1053, in initialize_plot
adjoined_plots.append(subplot.initialize_plot(ranges=ranges, plots=passed_plots))
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/bokeh/element.py", line 2175, in initialize_plot
child = subplot.initialize_plot(ranges, plot, plots)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/bokeh/element.py", line 1317, in initialize_plot
self._init_glyphs(plot, element, ranges, source)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/plotting/bokeh/element.py", line 1268, in _init_glyphs
style = self._apply_transforms(element, data, ranges, style)
File "/home/maxime/anaconda3/envs/spy/lib/python3.7/site-packages/holoviews/core/options.py", line 227, in __exit__
raise AbbreviatedException(etype, value, traceback)
AbbreviatedException: expected an element of either Seq(String), Seq(Tuple(String, String)) or Seq(Tuple(String, String, String)), got [nan]
任何人都知道我怎样才能让它工作?
复合对象是使用如下代码生成的:
import pandas as pd
import hvplot.pandas
import holoviews as hv
df1=pd.DataFrame({'dim1':[3,4,5], 'dim2':[1,1,2], 'a':[1,2,3], 'b':[1,2,3], 'c':[1,2,3]})
df2=df1.copy()
scatter1=df1.hvplot.scatter(x='a', y='b', c='c', groupby=['dim1', 'dim2'])
scatter2=df2.hvplot.scatter(x='a', y='b', c='grey', groupby=['dim1', 'dim2'])
hv.save(scatter1.layout('dim1'), 'object.html') # this works
composite_object = (scatter1*scatter2).collate().layout('dim1') # holoviews will create a slider to explore 'dim2', implicitly
hv.save(composite_object, 'object.html') # leads to AbbreviatedException when rendering to bokeh
谢谢你的帮助!