How to annotate heat maps in Makie.jl.
I was going through this post and the code in the question doesn’t seem to produce the text (numbers) on the heatmap.
The code is also provided below:
using DataFrames
using CSV
using CairoMakie
download("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/flights.csv", "flights.csv")
flights = DataFrame(CSV.File("flights.csv"))
data = Array(unstack(flights, :year, :month, :passengers)[!, 2:end])
fig = Figure()
ax = Axis(fig[1, 1], xlabel = "Year", ylabel = "Month")
hm = heatmap!(ax, data)
Colorbar(fig[1, 2], hm)
text!(ax,
string.(data'),
position = [Point2f(x, y) for x in 1:12 for y in 1:12],
align = (:center, :center),
color = ifelse.(data' .< 400, :white, :black),
textsize = 14,
)
save("figure.png", fig)
fig
The error that I get:
Desired output:
Any help is appreciated. Thanks!