本文整理匯總了Python中holoviews.Points方法的典型用法代碼示例。如果您正苦於以下問題:Python holoviews.Points方法的具體用法?Python holoviews.Points怎麽用?Python holoviews.Points使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類holoviews
的用法示例。
在下文中一共展示了holoviews.Points方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_taps_graph
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def create_taps_graph(self, x, y, clear=False):
"""
Create an output layer in the graph which responds to taps
Whenever the user taps (or clicks) the graph, a glyph will be overlaid,
and a series is extracted at that point.
"""
color = next(iter(self.color_pool))
if None not in [x, y]:
self.taps.append((x, y, color))
if self.control.kwargs['extract along'] is None:
self.taps = []
is_geo = self.kwargs['is_geo'] if 'is_geo' in self.kwargs else None
geo_disabled = self.control.projection.is_geo.disabled if is_geo else None
# Choose between gv.Points and hv.Points
if is_geo and geo_disabled is False:
tapped_map = gv.Points(self.taps, vdims=['z'])
else:
tapped_map = hv.Points(self.taps, vdims=['z'])
tapped_map.opts(color='z', marker='triangle', line_color='black',
size=8)
self.series_graph[0] = self.create_series_graph(x, y, color, clear)
return tapped_map
示例2: datashade_ndcurve
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [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
示例3: visualize_seeds
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def visualize_seeds(max_proj, seeds, mask=None, datashade=False):
h, w = max_proj.sizes['height'], max_proj.sizes['width']
asp = w/h
pt_cmap = {True: 'white', False: 'red'}
opts_im = dict(
plot=dict(frame_width=600, aspect=asp),
style=dict(cmap='Viridis'))
opts_pts = dict(
plot=dict(frame_width=600, aspect=asp,
size_index='seeds', color_index=mask, tools=['hover']),
style=dict(fill_alpha=0.8, line_alpha=0, cmap=pt_cmap))
if mask:
vdims = ['index', 'seeds', mask]
else:
vdims = ['index', 'seeds']
opts_pts['style']['color'] = 'white'
im = hv.Image(max_proj, kdims=['width', 'height'])
pts = hv.Points(seeds, kdims=['width', 'height'], vdims=vdims)
if datashade:
im = regrid(im)
return (im.opts(**opts_im) * pts.opts(**opts_pts))
示例4: clear_series
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def clear_series(self, *args):
"""
Clears the markers on the image, and the extracted series.
"""
if not self.clear_series_button.disabled:
self.series_graph[0] = pn.Spacer(name='Series Graph')
self.series = hv.Points([]).opts(frame_height=self.kwargs['frame_height'],
frame_width=self.kwargs['frame_width'])
self.taps.clear()
self.clear_points.event(clear=True)
示例5: setUp
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def setUp(self):
"Variations on the constructors in the Elements notebook"
self.points1 = Points([(1, i) for i in range(20)])
self.points2 = Points([(1, i) for i in range(21)])
self.points3 = Points([(1, i*2) for i in range(20)])
示例6: test_points_unequal_data_shape
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def test_points_unequal_data_shape(self):
try:
self.assertEqual(self.points1, self.points2)
except AssertionError as e:
if not str(e).startswith("Points not of matching length, 20 vs. 21."):
raise self.failureException("Points count mismatch error not raised.")
示例7: test_points_unequal_data_values
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def test_points_unequal_data_values(self):
try:
self.assertEqual(self.points1, self.points3)
except AssertionError as e:
if not str(e).startswith("Points not almost equal to 6 decimals"):
raise self.failureException("Points data mismatch error not raised.")
示例8: test_points_ellipsis_slice_x
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def test_points_ellipsis_slice_x(self):
sliced = hv.Points([(i,2*i) for i in range(10)])[2:7,...]
self.assertEqual(sliced.range('x'), (2,6))
示例9: test_points_ellipsis_slice_y
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def test_points_ellipsis_slice_y(self):
sliced = hv.Points([(i,2*i) for i in range(10)])[..., 3:9]
self.assertEqual(sliced.range('y'), (4,8))
示例10: create_figure
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def create_figure(x, y, color, size):
opts = dict(cmap='rainbow', width=800, height=600, line_color='black')
if color != 'None':
opts['color'] = color
if size != 'None':
opts['size'] = hv.dim(size).norm()*20
return hv.Points(df, [x, y], label="%s vs %s" % (x.title(), y.title())).opts(**opts)
示例11: test_pnwidget_hvplot_links
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def test_pnwidget_hvplot_links(document, comm):
size_widget = FloatSlider(value=5, start=1, end=10)
points1 = hv.Points([1, 2, 3])
size_widget.jslink(points1, value='glyph.size')
row = Row(points1, size_widget)
model = row.get_root(document, comm=comm)
hv_views = row.select(HoloViews)
widg_views = row.select(FloatSlider)
assert len(hv_views) == 1
assert len(widg_views) == 1
slider = widg_views[0]._models[model.ref['id']][0]
scatter = hv_views[0]._plots[model.ref['id']][0].handles['glyph']
link_customjs = slider.js_property_callbacks['change:value'][-1]
assert link_customjs.args['source'] is slider
assert link_customjs.args['target'] is scatter
code = """
var value = source['value'];
value = value;
value = value;
try {
var property = target.properties['size'];
if (property !== undefined) { property.validate(value); }
} catch(err) {
console.log('WARNING: Could not set size on target, raised error: ' + err);
return;
}
try {
target['size'] = value;
} catch(err) {
console.log(err)
}
"""
assert link_customjs.code == code
示例12: test_bkwidget_hvplot_links
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def test_bkwidget_hvplot_links(document, comm):
from bokeh.models import Slider
bokeh_widget = Slider(value=5, start=1, end=10, step=1e-1)
points1 = hv.Points([1, 2, 3])
Link(bokeh_widget, points1, properties={'value': 'glyph.size'})
row = Row(points1, bokeh_widget)
model = row.get_root(document, comm=comm)
hv_views = row.select(HoloViews)
assert len(hv_views) == 1
slider = bokeh_widget
scatter = hv_views[0]._plots[model.ref['id']][0].handles['glyph']
link_customjs = slider.js_property_callbacks['change:value'][-1]
assert link_customjs.args['source'] is slider
assert link_customjs.args['target'] is scatter
code = """
var value = source['value'];
value = value;
value = value;
try {
var property = target.properties['size'];
if (property !== undefined) { property.validate(value); }
} catch(err) {
console.log('WARNING: Could not set size on target, raised error: ' + err);
return;
}
try {
target['size'] = value;
} catch(err) {
console.log(err)
}
"""
assert link_customjs.code == code
示例13: test_hvplot_jscallback
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def test_hvplot_jscallback(document, comm):
points1 = hv.Points([1, 2, 3])
hvplot = HoloViews(points1)
hvplot.jscallback(**{'x_range.start': "some_code"})
model = hvplot.get_root(document, comm=comm)
x_range = hvplot._plots[model.ref['id']][0].handles['x_range']
customjs = x_range.js_property_callbacks['change:start'][-1]
assert customjs.args['source'] is x_range
assert customjs.code == "try { some_code } catch(err) { console.log(err) }"
示例14: _spatial_all
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def _spatial_all(self):
metas = self.metas
Asum = (regrid(hv.Image(
self.Asum.sel(**metas), ['width', 'height']), precompute=True)
.opts(plot=dict(
frame_height=len(self._h),
frame_width=len(self._w)),
style=dict(cmap='Viridis')))
cents = (hv.Dataset(
self.cents_sub.drop(list(self.meta_dicts.keys()), axis='columns'),
kdims=['width', 'height', 'unit_id'])
.to(hv.Points, ['width', 'height'])
.opts(style=dict(alpha=0.1,
line_alpha=0,
size=5,
nonselection_alpha=0.1,
selection_alpha=0.9))
.collate()
.overlay('unit_id')
.opts(plot=dict(tools=['hover', 'box_select'])))
self.strm_uid.source = cents
fim = fct.partial(hv.Image, kdims=['width', 'height'])
AC = (regrid(hv.DynamicMap(fim, streams=[self.pipAC]),
precompute=True)
.opts(plot=dict(
frame_height=len(self._h),
frame_width=len(self._w)),
style=dict(cmap='Viridis')))
mov = (regrid(hv.DynamicMap(fim, streams=[self.pipmov]),
precompute=True)
.opts(plot=dict(
frame_height=len(self._h),
frame_width=len(self._w)),
style=dict(cmap='Viridis')))
lab = fct.partial(hv.Labels, kdims=['width', 'height'], vdims=['unit_id'])
ulab = (hv.DynamicMap(lab, streams=[self.pipusub])
.opts(style=dict(text_color='red')))
return pn.panel(Asum * cents + AC * ulab + mov)
示例15: __init__
# 需要導入模塊: import holoviews [as 別名]
# 或者: from holoviews import Points [as 別名]
def __init__(self, data, initial_params={}):
super().__init__()
if not isinstance(data, xr.core.dataarray.DataWithCoords):
raise ValueError("Input should be an xarray data object, not %s" % type(data))
self.set_data(data)
self.initial_params = initial_params
self.control = Control(self.data)
self.plot_button = pn.widgets.Button(name='Plot', width=200,
disabled=True)
self.index_selectors = []
self.graph = pn.Spacer(name='Graph')
self.taps_graph = hv.Points([])
self.series_graph = pn.Row(pn.Spacer(name='Series Graph'))
self.clear_series_button = pn.widgets.Button(name='Clear',
width=200,
disabled=True)
self.output = pn.Row(self.graph,
pn.Column(name='Index_selectors'))
self._register(self.plot_button, 'plot_clicked', 'clicks')
self.connect('plot_clicked', self.create_graph)
self._register(self.control.coord_setter.coord_selector, 'set_coords')
self.connect("set_coords", self.set_coords)
self._register(self.clear_series_button, 'clear_series', 'clicks')
self.connect('clear_series', self.clear_series)
self.control.displayer.connect('variable_selected',
self.check_is_plottable)
self.control.displayer.connect('variable_selected',
self._link_aggregation_selectors)
self.control.fields.connect('x', self._link_aggregation_selectors)
self.control.fields.connect('y', self._link_aggregation_selectors)
self.panel = pn.Column(self.control.panel,
pn.Row(self.plot_button,
self.clear_series_button),
self.output,
self.series_graph, width_policy='max')
# To auto-select in case of single variable
if len(list(self.data.variables)) == 1:
self.control.displayer.select.value = self.data.variables[0]
self.control.setup_initial_values(self.initial_params)
self.taps = []
self.tap_stream = streams.Tap(transient=True)
colors = ['#60fffc', '#6da252', '#ff60d4', '#ff9400', '#f4e322',
'#229cf4', '#af9862', '#629baf', '#7eed5a', '#e29ec8',
'#ff4300']
self.color_pool = cycle(colors)
self.clear_points = hv.streams.Stream.define(
'Clear_points', clear=False)(transient=True)