Hi evrybody, I'm trying to overlay a scatter plot with a heatmap using Plots.jl bu

Hi evrybody, I’m trying to overlay a scatter plot with a heatmap using Plots.jl but I can’t figure it out how heatmap is oriented (or find much documentation on the plots.jl heatmap function).
The heat map seems turned by 90 degrees (or transposed, transposing the heat-value matrix seems to fix the issue). Maybe it fills row-wise from the top left corner while reading the array column-wise?
Here is an example showing the problem

n_points = 100
w = [4, 0.7, -2.3]
σ(a) = 1 / (1 + exp(-a))
x_data = randn(n_points) 
y_data = randn(n_points) 
y_data[1:n_points÷2] .+= 8
labels = [round(σ(p'*w)) for p in eachrow([ones(n_points) x_data y_data])]
plt = scatter(x_data, y_data, zcolor=labels)
xs = range(-4, 3, length=100)
ys = range(-4, 11, length=100)
grid = [[1, x, y] for x in xs, y in ys]
heat = [σ(p'*w) for p in grid]
heatmap!(plt, xs, ys, heat, alpha=0.5)
# this doesn't look right

# now transpose and it does
plt = scatter(x_data, y_data, zcolor=labels)
heatmap!(plt, xs, ys, transpose(heat), alpha=0.5)

Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the appropriate answer back to Slack, or pinging the poster here on Discourse so they can follow this thread.
(Original message :slack:) (More Info)

Well, you’ve solved your question, but FWIW, the reasoning is that heatmap’s orientation was made to match precedence (matplotlib IIRC), so the first dimension is the y axis and the second dimension is the x axis. This way, for example, taking a heatmap of a 3×5 matrix, as in

julia> heatmap(randn(3,5))

produces a 3×5 matrix-looing plot, i.e., something like

OP here.
Thanks for your answer, that background is exactly why I asked.
What I had did seem to fix it but it might have been a case of two mistakes cancelling each other out. It’s good to know that transposing the heatmap is the general solution to my problem.