Hi- Tried using annotation according to the docs and receiving a recipe error. A minimum viable example is provide below which is very similar to the docs example.
ts = rand(10,2)
lbs = string.(1:10)
f = Figure()
ax = Axis(f[1,1], xlabel="x", ylabel="y")
scatter!(ax, pts)
text!(ax, pts, text = lbs)
ax2 = Axis(f[1,2], xlabel="x", ylabel="y")
scatter!(ax2, pts)
annotation!(ax2, pts, text = lbs)
f
Note that in the documentation example, points is a Vector{Tuple{Float64, Float64}}, while you’re supplying a Matrix. If you also use that here, via
annotation!(ax2, Tuple.(eachrow(pts)), text = lbs)
everything works fine.
In general it’s often unclear to me when Makie will accept a Matrix (normally you’d use 2 \times n though), but in my experience, a Vector{Point2f} (or Vector{Point3f} in 3D) never gives any issues and is more descriptive than a Matrix. So when in doubt, I’d advise to use that.
annotation!(ax2, Point2f.(eachrow(pts)), text = lbs)
f = Figure()
ax = Axis(f[1,1], xlabel="x", ylabel="y")
scatter!(ax, pts)
text!(ax, pts, text = lbs)
ax2 = Axis(f[1,2], xlabel="x", ylabel="y")
scatter!(ax2, pts)
# Fix: Convert matrix to individual points for annotation!
for i in 1:size(pts, 1)
annotation!(ax2, pts[i,1], pts[i,2], text = lbs[i])
end
f
It’s just a missing convert, I didn’t reuse the PointLike trait because the signature can be more complex, so some conversions you’re used to from scatter etc. are probably missing, like the matrix here
Ah, thanks. I should have dug a little more and caught that. I think i was more surprised that text! and annotation! responded differently to same input.