Heatmap where x-labels and y-labels are strings

Could any one please help me with plotting a heatmap when x-axis and y-axis are strings.
For example, the following code would work:

using CairoMakie

xs = 1:5
ys = 1:10
zs = [rand(1)[1] for x in xs, y in ys]
heatmap(xs, ys, zs)

but the following would error because x and y are strings:

using CairoMakie

xs = "a" .* string.(1:5)
ys = "b" .* string.(1:10)
zs = [rand(1)[1] for x in xs, y in ys]
heatmap(xs, ys, zs)

With PlotlyJS.jl you can plot such a heatmap:

using PlotlyJS
plot(heatmap(x= xs, y=ys, z=zs', colorscale=colors.matter), 
     Layout(width=400, height=600))

1 Like

Thank you for your response @empet.

You might be interested in a solution I figured using CairoMakie as follows. Might not be the best way of doing things:

using CairoMakie

xs = "a" .* string.(1:5)
ys = "b" .* string.(1:10)
zs = [rand(1)[1] for x in xs, y in ys]

heatmap([1:5;], [1:10;], zs, axis=(xticks=(1:5, xs), yticks=(1:10, ys), xticklabelrotation = pi/4) )