Heatmap Plots.jl

Good afternoon!

I can not get the heatmap plot in the Plots.jl package to do what I would like.

If I do:

using Plots
p = heatmap([1,2,3,1,2,3,1,2,3],[1,1,1,2,2,2,3,3,3],[1,1,1,1,1,1,1,1,1])

I get the result:

while I expect some kind of plot homogeneously filled with ones. (maybe from 0,5 to 3,5 in x and y?)

What am I missing?

heatmap plots a heatmap of a rectangular matrix z, which is your


despite that this isn’t a rectengular matrix.

Try first

heatmap([1 1 1;1 1 1;1 1 1])

which results in your expectation.
Or to have it more visually appealing:

heatmap([1 2 3;3 2 1;2 3 1])

To provide x and y labels you use x and y vectors of strings

heatmap(["1","2","3"],["1","2","3"],[1 2 3;2 3 1;3 1 1])

See examples in the docs:

1 Like

Thank you so much for a great answer! That solved my problems!

Actually it seems that you can provide it with integers instead of strings for “categories” and it will be smart enough to handle that too.

1 Like