# Plot one point with a label

I would like to plot labeled points. The code I wrote to try it out is below.

using CairoMakie
function point(x; label=L"%\$x")
scatter!((x, 0);color=:black)
text!(label, position=(x-0.05, 0.1))
end
fig, ax=lines(-3:3, 0:0;figure=(;resolution=(600, 200)), color=:black)
point(1)
point(ℯ)
point(sqrt(2), label=L"\sqrt{2}")
point(2//3, label=L"\frac{2}{3}")
limits!(ax, 0, 3, -1, 1)
hidedecorations!(ax)
hidespines!(ax)
fig


The labeling is ugly.

What is a better way?

“ugly” is subjective, do you mean the alignment is not centered? Use this instead:

text!(label, position=(x, 0.1), align = (:center, :bottom))


Also note that for Latex strings, the additional lines currently only work in plain Scenes without projection, you can see that there are none in the fraction or the square root. That’s a bug that should be fixed one of these days.

2/3 and sqrt2 are obviously ugly. e also looks weird.

Note that you use the Unicode Symbol ℯ for the LaTeXString. With point(ℯ, label=L"\mathbf{e}") I get: