Annotations in Makie.jl

Is it currently possible to annotate Makie-plots? I am thinking about having text at the root of an arrow that point to some location in the plot. I am imagining that one could DIY it by plotting a vector, and possible plotting a point at it’s root with the marker being some text, but are there any build-in, convenient features for this? I can’t seem to find any.

http://makie.juliaplots.org/stable/abstractplotting_api.html#AbstractPlotting.annotations-Tuple

Something like:

julia> points = [Point2f0(cos(t), sin(t)) for t in LinRange(0, 2pi, 20)];

julia> colors = 1:20;

julia> figure, axis, scatterobject = scatter(points, color = colors, markersize = 15);

julia> AbstractPlotting.annotations!(string.('a':'z')[1:20], points, textsize = 0.1, font = "JuliaMono")
Annotations{Tuple{Vector{Tuple{String, Point{2, Float32}}}}}

EDIT: Apologies, my initial draft didn’t use JuliaMono font!

5 Likes

This example doesn’t really show that text is currently always drawn with axis scaling applied, so if your scaling is not approximately equal, the text will be really stretched. I have a PR waiting to fix this but the GLMakie support is still missing that PR is now merged

4 Likes

Can this be done for a single subplot? I naively hoped annotations!(ax, "text", (0,0)) might work but alas not implemented.

There is text!(ax, "text", position=(0,0), space = :data), see text

(I think that is the annotations replacement in current Makie.)

6 Likes