import holoviews as hv import numpy as np import panel as pn hv.extension('bokeh') points = hv.Points([(0.0, 0.0), (1.0, 1.0), (200000.0, 2000000.0)]).opts(size=10, min_height=500) annotator = hv.annotate.instance() layout = annotator(hv.element.tiles.OSM() * points, annotations=['Label'], name="Point Annotations") print(layout) layout annotator.annotated.dframe() annotator.selected.dframe() hv.help(hv.annotate) hv.annotate(points, annotations={'int': int, 'float': float, 'str': str}) curve = hv.Curve(np.random.randn(50).cumsum()) curve_annotator = hv.annotate.instance() curve_annotator(curve.opts(width=800, height=400, responsive=False), annotations={'Label': str}) curve_annotator.annotated.dframe().head(5) boxes = hv.Rectangles([(0, 0, 1, 1), (1.5, 1.5, 2.5, 2.5)]) box_annotator = hv.annotate.instance() box_annotator(boxes.opts(width=800, height=400, responsive=False), annotations=['Label']) box_annotator.annotated.dframe() path = hv.Path([hv.Box(0, 0, 1), hv.Ellipse(1, 1, 1)]) path_annotator = hv.annotate.instance() path_annotator(path.opts(width=800, height=400, responsive=False), annotations=['Label'], vertex_annotations=['Value']) path_annotator.annotated.iloc[0].dframe() img = hv.Image(np.load('../assets/twophoton.npz')['Calcium'][..., 0]) cells = hv.Points([]).opts(width=500, height=500, responsive=False, padding=0) hv.annotate(img * cells, annotations=['Label'], name="Cell Annotator") point_annotate = hv.annotate.instance() points = hv.Points([(500000, 500000), (1000000, 1000000)]).opts(size=10, color='red', line_color='black') point_layout = point_annotate(points, annotations=['Label']) poly_annotate = hv.annotate.instance() poly_layout = poly_annotate(hv.Polygons([]), annotations=['Label']) hv.annotate.compose(hv.element.tiles.OSM(), point_layout, poly_layout) print(point_annotate.annotator) #point_annotate.annotator.object = hv.Points(np.random.randn(10, 2)*1000000).opts(color='blue')