Skip to content

Commit

Permalink
Add small section about annotate internals
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jan 7, 2020
1 parent 708244f commit 52d30d1
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions examples/user_guide/Annotators.ipynb
Expand Up @@ -266,15 +266,49 @@
"metadata": {},
"outputs": [],
"source": [
"point_annotator = annotate.instance()\n",
"point_annotate = annotate.instance()\n",
"points = hv.Points([(500000, 500000), (1000000, 1000000)]).opts(size=10, color='red', line_color='black')\n",
"point_layout = point_annotator(points, annotations=['Label'])\n",
"point_layout = point_annotate(points, annotations=['Label'])\n",
"\n",
"poly_annotator = annotate.instance()\n",
"poly_layout = poly_annotator(hv.Polygons([]), annotations=['Label'])\n",
"poly_annotate = annotate.instance()\n",
"poly_layout = poly_annotate(hv.Polygons([]), annotations=['Label'])\n",
"\n",
"annotate.compose(hv.element.tiles.Wikipedia(), point_layout, poly_layout)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Internals\n",
"\n",
"The `annotate` function builds on param and [panel](https://panel.holoviz.org) and wraps `Annotator` panes internally. These objects make it easy to include the annotator in param based workflows and trigger actions when parameters change and/or update the annotator in response to external events. The Annotator of a `annotate` instance can be accessed using the `annotator` attribute:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(point_annotate.annotator)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This object can be included directly in a Panel layout, be used to watch for parameter changes, or updated directly:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"point_annotate.annotator.object = hv.Points(np.random.randn(10, 2)*1000000).opts(color='red')"
]
}
],
"metadata": {
Expand Down

0 comments on commit 52d30d1

Please sign in to comment.