Basics#

Basics#

Note

What you see in this notebook will depend on whether you’ve run this notebook before and written annotations to the annotations.db database! For reproducibility, the rest of the notebook will assume the annotations.db has been deleted (if it exists).

Setup#

This basic example will be of a time series where we want to annotate various time intervals to illustrate the basics of the annotation system. Note that annotators can annotate all sorts of elements (e.g., Image, Scatter, etc.) with many different region types, which will be demonstrated later.

import hvplot.pandas
import numpy as np
import pandas as pd
from holonote.annotate import Annotator


speed_data = pd.read_parquet('../assets/example.parquet')
speed_curve = speed_data.hvplot('TIME', 'SPEED')
speed_curve

In the simplest case, simply wrap the element (here in a curve) in an Annotator:

annotator = Annotator(speed_curve, fields=['description'])

The fields argument lists the fields associated with the annotations we will be defining. When working with tabular data (the typical case), you can think of fields as the columns of your table containing information about annotated regions.

Here we supplied an element to annotator to the Annotator but note that most of the functionality of annotators can be made available by specifying the key dimensions and their types. The following is equivalent to the above declaration:

annotator = Annotator({'TIME': np.datetime64}, fields=['description'])

Now we can create an overlay of our element, a dynamicmap that shows the defined annotation regions and a dynamicmap used to define new regions:

annotator * speed_curve  # If you have a database file generated by a previous run, your annotations will now be displayed