# How to annotate on heatmaps in Makie.jl

**URL:** <https://discourse.julialang.org/t/how-to-annotate-on-heatmaps-in-makie-jl/89506>\
**Category:** Visualization\
**Tags:** package, plotting, makie\
**Created:** [October 30, 2022, 12:40am UTC](https://discourse.julialang.org/t/how-to-annotate-on-heatmaps-in-makie-jl/89506 "2022-10-30T00:40:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [October 30, 2022, 12:40am UTC](https://discourse.julialang.org/t/how-to-annotate-on-heatmaps-in-makie-jl/89506/1 "2022-10-30T00:40:00Z")

</div>

How to annotate heat maps in Makie.jl.

I was going through this [post](https://discourse.julialang.org/t/makie-how-to-set-custom-x-and-y-tick-values-in-a-makie-heatmap/81397) and the code in the question doesn’t seem to produce the text (numbers) on the heatmap.

The code is also provided below:

```julia-auto
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:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/a/da32d758c4bd757f4fed5a6683349dda3237c676.png)

Desired output:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/5/052c9b1e5eee2568cb56b45a8ceecc4a29f2ad49.png)

Any help is appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [October 30, 2022, 12:45am UTC](https://discourse.julialang.org/t/how-to-annotate-on-heatmaps-in-makie-jl/89506/2 "2022-10-30T00:45:50Z")

</div>

Do you need that example in particular?

You could take a look at the BeautifulMakie example which should be up to date

> **[heatmap with text - Beautiful Makie](https://beautiful.makie.org/dev/examples/generated/2d/heatmaps/text_heatmap/)**
>
> Makie Examples

(saying because apart from version changes in makie, that other file could have changed since the original post).

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [October 30, 2022, 1:06am UTC](https://discourse.julialang.org/t/how-to-annotate-on-heatmaps-in-makie-jl/89506/3 "2022-10-30T01:06:10Z")

</div>

Amazing! The example on the link you provided works perfectly for my case as well. Thanks.

---

<div class="post-metadata">

**Author:** ![jacobusmmsmit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacobusmmsmit/32/217669_2.png) [@jacobusmmsmit](https://discourse.julialang.org/u/jacobusmmsmit)\
**Post date:** [September 3, 2025, 2:32pm UTC](https://discourse.julialang.org/t/how-to-annotate-on-heatmaps-in-makie-jl/89506/4 "2025-09-03T14:32:18Z")

</div>

Sorry to necro this thread but here’s an updated link: [Beautiful Makie](https://beautiful.makie.org/dev/examples/2d/heatmaps/text_heatmap)
