How to add value labels on top of contours in Makie?

To have it documented here for posterity:

This amazing PR by @t-bltg was just merged into master, so now (April 1, 2023) it will be possible to do:

using CairoMakie

main() = begin
  paraboloid = (x, y) -> 10(x^2 + y^2)
  x = range(-3, 3; length = 100)
  y = range(-3, 3; length = 200)
  z = paraboloid.(x, y')

  fig, ax, hm = heatmap(x, y, z; interpolate = true)
  Colorbar(fig[1, 2], hm)

  contour!(
    ax, x, y, z;
    color = :red, levels = 0:10:100, labels = true,
    labelsize = 15, labelfont = :bold, labelcolor = :orange
  )

  save("contour_labels_2d.png", fig)
  fig
end

main()

That produces:

6 Likes