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
backend(:plotly)
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])
gui(p)

I get the result:
newplot

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

[1,1,1,1,1,1,1,1,1]

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:
http://docs.juliaplots.org/latest/generated/plotly/#plotly-ref28-1

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