How to correctly use heatmap with 3 vectors as input?

When using heatmap as the example shows:

using CairoMakie

xls = range(0, 10, length = 25)
yls = range(0, 15, length = 25)
zm = [cos(x) * sin(y) for x in xs, y in ys]

heatmap(xls, yls, zm)

I can get the result expected:

But when I transfer the data into 3 vectors in the spirit of the example and do the plot

xs = Float64[]
ys = Float64[]
zs = Float64[]
for x in xls
    append!(xs, [x for _ in 1:length(yls)])
    append!(ys, yls)
    append!(zs, cos(x) .* sin.(yls))
end
heatmap(xs, ys, zs)

I got something weird:

Am I missing something here? I have checked the order of data in xs, ys and zs but did’t figure it out.

This was a floating point conversion bug, thanks for reporting! Should be fixed here: https://github.com/JuliaPlots/Makie.jl/pull/1365/files

Maybe the following question is kind of dummy but I am not a professional git user. Do I have to wait until the pull request is accepted and a new version is published so that I can up CairoMakie and do the plot correctly? I mean, if this takes a lot of time, how can I use the corrected version ASAP?

julia>] add Makie#jk/fix-heatmap-vector-conversion

1 Like

Awesome!

I can do this in one remote server and locally on my pc, but not in another remote server. The following is the error info:

(@v1.6) pkg> add Makie#jk/fix-heatmap-vector-conversion
     Cloning git-repo `https://github.com/JuliaPlots/Makie.jl.git`
ERROR: git repository not found at `https://github.com/JuliaPlots/Makie.jl.git`

I am wondering if you have some idea on how to fix this? Or maybe I can add this package manually but I don’t know how to do it.

Could be that the remote server has firewall settings that block git via https, at least my workplace has something similar going on. You could try to just ping the git page on that server and see if it connects at all.

1 Like