Skip to main content

Annotation

Annotation[expr_, data_]

represents an expression expr annotated with data. This kind of annotation is not visible on output

a = Table[Annotation[i, PrimeQ[i]], {i, 20}]
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}

Now find annotated data

Cases[a, Annotation[_, True]]
{2,3,5,7,11,13,17,19}

Another use-case with graphs

Annotation[item_, key_->value_]

associates key-value pairs with items in objects such as GraphMeshRegion etc. For example

Graph[{Annotation[1 <-> 2, EdgeLabels -> "hello"], 
2 <-> 3, 3 <-> 1}]