本文整理匯總了Python中holoviews.NdOverlay方法的典型用法代碼示例。如果您正苦於以下問題:Python holoviews.NdOverlay方法的具體用法?Python holoviews.NdOverlay怎麽用?Python holoviews.NdOverlay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類holoviews
的用法示例。
在下文中一共展示了holoviews.NdOverlay方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _pos_indicator
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def _pos_indicator(self, obj, x):
"""
Returns an NdOverlay of Points indicating the current
mouse position along the cross-sections.
Note: Because the function returns an NdOverlay containing
a variable number of elements batching must be enabled and
the legend_limit must be set to 0.
"""
points = []
elements = obj or []
for el in elements:
if len(el)<1:
continue
p = Points(el[x], ['x', 'y'], crs=ccrs.GOOGLE_MERCATOR)
points.append(p)
if not points:
return NdOverlay({0: Points([], ['x', 'y'])})
return NdOverlay(enumerate(points))
示例2: test_dynamic_compute_overlayable_zorders_mixed_dynamic_and_non_dynamic_ndoverlays
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_dynamic_compute_overlayable_zorders_mixed_dynamic_and_non_dynamic_ndoverlays(self):
ndoverlay = NdOverlay({i: Area(range(10+i)) for i in range(2)})
curve = DynamicMap(lambda: Curve(range(10)), kdims=[])
curve_redim = curve.redim(x='x2')
combined = ndoverlay*curve_redim
combined[()]
sources = compute_overlayable_zorders(combined)
self.assertIn(ndoverlay[0], sources[0])
self.assertIn(ndoverlay, sources[0])
self.assertNotIn(curve_redim, sources[0])
self.assertNotIn(curve, sources[0])
self.assertIn(ndoverlay[1], sources[1])
self.assertIn(ndoverlay, sources[1])
self.assertNotIn(curve_redim, sources[1])
self.assertNotIn(curve, sources[1])
self.assertIn(curve_redim, sources[2])
self.assertIn(curve, sources[2])
self.assertNotIn(ndoverlay, sources[2])
示例3: test_dynamic_compute_overlayable_zorders_mixed_dynamic_and_dynamic_ndoverlay_with_streams
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_dynamic_compute_overlayable_zorders_mixed_dynamic_and_dynamic_ndoverlay_with_streams(self):
ndoverlay = DynamicMap(lambda x: NdOverlay({i: Area(range(10+i)) for i in range(2)}),
kdims=[], streams=[PointerX()])
curve = DynamicMap(lambda: Curve(range(10)), kdims=[])
curve_redim = curve.redim(x='x2')
combined = ndoverlay*curve_redim
combined[()]
sources = compute_overlayable_zorders(combined)
self.assertIn(ndoverlay, sources[0])
self.assertNotIn(curve_redim, sources[0])
self.assertNotIn(curve, sources[0])
self.assertIn(ndoverlay, sources[1])
self.assertNotIn(curve_redim, sources[1])
self.assertNotIn(curve, sources[1])
self.assertIn(curve_redim, sources[2])
self.assertIn(curve, sources[2])
self.assertNotIn(ndoverlay, sources[2])
示例4: test_dynamic_compute_overlayable_zorders_mixed_dynamic_and_dynamic_ndoverlay_with_streams_cloned
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_dynamic_compute_overlayable_zorders_mixed_dynamic_and_dynamic_ndoverlay_with_streams_cloned(self):
ndoverlay = DynamicMap(lambda x: NdOverlay({i: Area(range(10+i)) for i in range(2)}),
kdims=[], streams=[PointerX()])
curve = DynamicMap(lambda: Curve(range(10)), kdims=[])
curve_redim = curve.redim(x='x2')
combined = ndoverlay*curve_redim
combined[()]
sources = compute_overlayable_zorders(combined.clone())
self.assertIn(ndoverlay, sources[0])
self.assertNotIn(curve_redim, sources[0])
self.assertNotIn(curve, sources[0])
self.assertIn(ndoverlay, sources[1])
self.assertNotIn(curve_redim, sources[1])
self.assertNotIn(curve, sources[1])
self.assertIn(curve_redim, sources[2])
self.assertIn(curve, sources[2])
self.assertNotIn(ndoverlay, sources[2])
示例5: test_dynamic_compute_overlayable_zorders_mixed_dynamic_and_non_dynamic_ndoverlays_reverse
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_dynamic_compute_overlayable_zorders_mixed_dynamic_and_non_dynamic_ndoverlays_reverse(self):
ndoverlay = NdOverlay({i: Area(range(10+i)) for i in range(2)})
curve = DynamicMap(lambda: Curve(range(10)), kdims=[])
curve_redim = curve.redim(x='x2')
combined = curve_redim*ndoverlay
combined[()]
sources = compute_overlayable_zorders(combined)
self.assertIn(curve_redim, sources[0])
self.assertIn(curve, sources[0])
self.assertNotIn(ndoverlay, sources[0])
self.assertIn(ndoverlay[0], sources[1])
self.assertIn(ndoverlay, sources[1])
self.assertNotIn(curve_redim, sources[1])
self.assertNotIn(curve, sources[1])
self.assertIn(ndoverlay[1], sources[2])
self.assertIn(ndoverlay, sources[2])
self.assertNotIn(curve_redim, sources[2])
self.assertNotIn(curve, sources[2])
示例6: datashade_ndcurve
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def datashade_ndcurve(ovly, kdim=None, spread=False):
if not kdim:
kdim = ovly.kdims[0].name
var = np.unique(ovly.dimension_values(kdim)).tolist()
color_key = [(v, Category10_10[iv]) for iv, v in enumerate(var)]
color_pts = hv.NdOverlay(
{k: hv.Points([0, 0], label=str(k)).opts(style=dict(color=v)) for k, v in color_key})
ds_ovly = datashade(
ovly,
aggregator=count_cat(kdim),
color_key=dict(color_key),
min_alpha=200,
normalization='linear')
if spread:
ds_ovly = dynspread(ds_ovly)
return ds_ovly * color_pts
示例7: _sample
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def _sample(self, obj, data):
"""
Rasterizes the supplied object in the current region
and samples it with the drawn paths returning an
NdOverlay of Curves.
Note: Because the function returns an NdOverlay containing
a variable number of elements batching must be enabled and
the legend_limit must be set to 0.
"""
if self.path_stream.data is None:
path = self.path
else:
path = self.path_stream.element
if isinstance(obj, TriMesh):
vdim = obj.nodes.vdims[0]
else:
vdim = obj.vdims[0]
if len(path) > 2:
x_range = path.range(0)
y_range = path.range(1)
else:
return NdOverlay({0: Curve([], 'Distance', vdim)})
(x0, x1), (y0, y1) = x_range, y_range
width, height = (max([min([(x1-x0)/self.resolution, 500]), 10]),
max([min([(y1-y0)/self.resolution, 500]), 10]))
raster = rasterize(obj, x_range=x_range, y_range=y_range,
aggregator=self.aggregator, width=int(width),
height=int(height), dynamic=False)
x, y = raster.kdims
sections = []
for g in path.geom():
xs, ys, distance = self._gen_samples(g)
indexes = {x.name: xs, y.name: ys}
points = raster.data.sel_points(method='nearest', **indexes).to_dataframe()
points['Distance'] = distance
sections.append(Curve(points, 'Distance', vdims=[vdim, x, y]))
return NdOverlay(dict(enumerate(sections)))
示例8: test_plot
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_plot(sample1_datasource):
pytest.importorskip('hvplot')
import holoviews
p = sample1_datasource.plot()
assert isinstance(p, holoviews.NdOverlay)
示例9: test_wide_chart
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_wide_chart(self, kind, element):
plot = self.df.hvplot(kind=kind)
obj = NdOverlay({'x': element(self.df, 'index', 'x').redim(x='value'),
'y': element(self.df, 'index', 'y').redim(y='value')}, 'Variable')
self.assertEqual(plot, obj)
示例10: test_wide_chart_labels
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_wide_chart_labels(self, kind, element):
plot = self.df.hvplot(kind=kind, value_label='Test', group_label='Category')
obj = NdOverlay({'x': element(self.df, 'index', 'x').redim(x='Test'),
'y': element(self.df, 'index', 'y').redim(y='Test')}, 'Category')
self.assertEqual(plot, obj)
示例11: test_tidy_chart_index_by
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_tidy_chart_index_by(self, kind, element):
plot = self.df.hvplot(x='index', y='y', by='x', kind=kind)
obj = NdOverlay({1: element(self.df[self.df.x==1], 'index', 'y'),
3: element(self.df[self.df.x==3], 'index', 'y'),
5: element(self.df[self.df.x==5], 'index', 'y')}, 'x')
self.assertEqual(plot, obj)
示例12: test_area_stacked
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_area_stacked(self):
plot = self.df.hvplot.area(stacked=True)
obj = NdOverlay({'x': Area(self.df, 'index', 'x').redim(x='value'),
'y': Area(self.df, 'index', 'y').redim(y='value')}, 'Variable')
self.assertEqual(plot, Area.stack(obj))
示例13: test_only_includes_num_chart
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_only_includes_num_chart(self, kind, element):
plot = self.cat_df.hvplot(kind=kind)
obj = NdOverlay({'x': element(self.cat_df, 'index', 'x').redim(x='value'),
'y': element(self.cat_df, 'index', 'y').redim(y='value'),
}, 'Variable')
self.assertEqual(plot, obj)
示例14: setUp
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def setUp(self):
self.dmap_element = DynamicMap(lambda: Image([]))
self.dmap_overlay = DynamicMap(lambda: Overlay([Curve([]), Points([])]))
self.dmap_ndoverlay = DynamicMap(lambda: NdOverlay({0: Curve([]), 1: Curve([])}))
self.element = Scatter([])
self.el1, self.el2 = Path([]), HLine(0)
self.overlay = Overlay([self.el1, self.el2])
self.ndoverlay = NdOverlay({0: VectorField([]), 1: VectorField([])})
示例15: test_overlay
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import NdOverlay [as 別名]
def test_overlay(self):
NdOverlay(list(enumerate([self.view1, self.view2, self.view3])))