# How to correctly use heatmap with 3 vectors as input?

**URL:** <https://discourse.julialang.org/t/how-to-correctly-use-heatmap-with-3-vectors-as-input/69191>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [October 4, 2021, 1:18pm UTC](https://discourse.julialang.org/t/how-to-correctly-use-heatmap-with-3-vectors-as-input/69191 "2021-10-04T13:18:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![thudjx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thudjx/32/15231_2.png) [@thudjx](https://discourse.julialang.org/u/thudjx)\
**Post date:** [October 4, 2021, 1:18pm UTC](https://discourse.julialang.org/t/how-to-correctly-use-heatmap-with-3-vectors-as-input/69191/1 "2021-10-04T13:18:19Z")

</div>

When using `heatmap` as [the example](https://makie.juliaplots.org/stable/examples/plotting_functions/heatmap/#two_vectors_and_a_matrix) shows:

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

 ![heatmap1](https://global.discourse-cdn.com/julialang/original/3X/4/c/4c2c3801d78f16d78547a59f6e0e196376cba536.png)

But when I transfer the data into 3 vectors in the spirit of [the example](https://makie.juliaplots.org/stable/examples/plotting_functions/heatmap/#three_vectors) and do the plot

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

 ![heatmap2](https://global.discourse-cdn.com/julialang/original/3X/6/4/6408cd9417c170b25869240e2d5cc62143d65df2.png)

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 5, 2021, 11:40am UTC](https://discourse.julialang.org/t/how-to-correctly-use-heatmap-with-3-vectors-as-input/69191/2 "2021-10-05T11:40:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thudjx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thudjx/32/15231_2.png) [@thudjx](https://discourse.julialang.org/u/thudjx)\
**Post date:** [October 5, 2021, 1:01pm UTC](https://discourse.julialang.org/t/how-to-correctly-use-heatmap-with-3-vectors-as-input/69191/3 "2021-10-05T13:01:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [October 5, 2021, 1:17pm UTC](https://discourse.julialang.org/t/how-to-correctly-use-heatmap-with-3-vectors-as-input/69191/4 "2021-10-05T13:17:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thudjx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thudjx/32/15231_2.png) [@thudjx](https://discourse.julialang.org/u/thudjx)\
**Post date:** [October 5, 2021, 1:31pm UTC](https://discourse.julialang.org/t/how-to-correctly-use-heatmap-with-3-vectors-as-input/69191/5 "2021-10-05T13:31:31Z")

</div>

Awesome!

---

<div class="post-metadata">

**Author:** ![thudjx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thudjx/32/15231_2.png) [@thudjx](https://discourse.julialang.org/u/thudjx)\
**Post date:** [October 5, 2021, 3:20pm UTC](https://discourse.julialang.org/t/how-to-correctly-use-heatmap-with-3-vectors-as-input/69191/6 "2021-10-05T15:20:41Z")

</div>

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:

```julia
(@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.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 5, 2021, 5:11pm UTC](https://discourse.julialang.org/t/how-to-correctly-use-heatmap-with-3-vectors-as-input/69191/7 "2021-10-05T17:11:18Z")

</div>

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.
