# Heatmap where x-labels and y-labels are strings

**URL:** https://discourse.julialang.org/t/heatmap-where-x-labels-and-y-labels-are-strings/71963
**Category:** Visualization
**Tags:** plotting, makie, algebraofgraphics
**Created:** [November 23, 2021, 6:29pm UTC](https://discourse.julialang.org/t/heatmap-where-x-labels-and-y-labels-are-strings/71963 "2021-11-23T18:29:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Rahul](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rahul/32/30545_2.png) [@Rahul](https://discourse.julialang.org/u/Rahul)
#### Post date: [November 23, 2021, 6:29pm UTC](https://discourse.julialang.org/t/heatmap-where-x-labels-and-y-labels-are-strings/71963/1 "2021-11-23T18:29:05Z")

</div>

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:

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

```julia
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)

```

---

<div class="post-metadata">

### Author: ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)
#### Post date: [November 23, 2021, 8:08pm UTC](https://discourse.julialang.org/t/heatmap-where-x-labels-and-y-labels-are-strings/71963/2 "2021-11-23T20:08:55Z")

</div>

With PlotlyJS.jl you can plot such a heatmap:

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

```

 ![heatmap_strings](https://global.discourse-cdn.com/julialang/original/3X/e/8/e8094d88d8dad3644f0fb2ab831e8178a37d8d6f.png)

---

<div class="post-metadata">

### Author: ![Rahul](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rahul/32/30545_2.png) [@Rahul](https://discourse.julialang.org/u/Rahul)
#### Post date: [November 23, 2021, 8:28pm UTC](https://discourse.julialang.org/t/heatmap-where-x-labels-and-y-labels-are-strings/71963/3 "2021-11-23T20:28:06Z")

</div>

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:

```julia
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) )

```
