How to put a single marker on a heatmap

I’m using CairoMakie to make a heatmap in Julia 1.7.3

I’d like to add a single smiley face (or really any marker) in the very center of the heatmap, at say 50 x 50.

This seems like a super simple task, but I’ve been looking online and haven’t found anything. The most basic thing to do would seem to be use scatter, which I can make work if I have multiple points, but not if I only want to put one.

Can anyone point me in the right direction?

I think your single points just need to be wrapped in a vector:

using CairoMakie

fig = Figure()
ax = Axis(fig[1, 1])

heatmap!(ax, rand(4, 4))
scatter!(ax, [2.5], [2.5]; marker='😃', markersize=100)

# Can also use a Point
scatter!(ax, Point(3.5, 1.5); marker='😃', markersize=100)

fig

Edit: added an example using Point

1 Like

Or one Point

amazing thank you!!

for some reason this did not work for me…

What did you try exactly with the Point?

Thanks, added an example using Point

Is there a reference somewhere showing the relationship between Point, Point2, and Point2f by the way? I think I saw that Point2f0 was deprecated at some point (no pun intended), but I have trouble keeping them all straight to be honest :sweat_smile:

Curious. What happens under the hood so that the smiley ends up in the image (it even changes its line color) as
image

Not really a reference but here is a quick explanation.

The main type is Point{N, T}, where N is an integer and T is the element type. So Point2 is Point{2, T}, and Point2f is Point{2, Float32}.

Point2f0 was the same as Point2f. The naming was in mimicry of the 1f0 notation to denote Float32 literals.

1 Like

Basically, there are two factors at play - the font and the rendering system. A lot of fonts don’t explicty support empjis, or have simple vector forms as opposed to the complex emojis we are used to.

Furthermore, in GLMakie we render all text in a specific way (signed distance fields) which allows a glyph to be rendered smoothly but loses the color information.

These two factors mean that Makie is not necessarily that good at rendering emojis. If you find a good font, CairoMakie may do better.

Cairo cannot render such multicolor glyphs at all. They’d require bit of a special treatment, and as Anshul said, GLMakie’s pipeline can only handle single color anyway. So it’s not likely to ever be added. However if one truly needed to plot emoji markers, one could always get their hands on bitmaps and plot these as scatter markers.

Thanks. As I said, this was out of curiosity because what was plotted was not the emoji itself but simplification of it. I think Cairo is not so different of GMT (which has its own PostScript library) and in it we can make symbols out of any postscript file, so plotting emojis would be a matter of creating PS versions of them.

It’s not a simplification, it’s a different glyph associated with the same unicode character.