Patrick
Patrick

Reputation: 51

plots.jl heatmap does not preserve orientation

I'm trying to use the heatmap function fro plots.jl as a simple means to visualize small grayscale pixel grids. But I've discovered that this function does not preserve the orientation of the matrix it plots. For example:

julia> using Random, Plots

julia> mymatrix = zeros(Int, (5,5))
10x10 Matrix{Int64}:
 0  0  0  0  0
 0  0  0  0  0
 0  0  0  0  0
 0  0  0  0  0
 0  0  0  0  0

julia> mymatrix[1,1] = 1
1

julia> mymatrix
5x5 Matrix{Int64}
 1  0  0  0  0
 0  0  0  0  0
 0  0  0  0  0
 0  0  0  0  0
 0  0  0  0  0

julia> heatmap(mymatrix, color = :greys)

Which results in the following image:

heatmap of binary matrix

You can see that the heatmap function transforms the provided matrix. From the examples I have tested, it is clear that a vertical reflection is applied. I cannot find anything in the documentation about this behavior. I am looking for a way to avoid or corrected it, ideally without changing the input matrix. Any suggestions are appreciated.

Thanks,

Upvotes: 1

Views: 377

Answers (1)

Bogumił Kamiński
Bogumił Kamiński

Reputation: 69949

use the yflip keyword argument:

heatmap(mymatrix, color=:greys, yflip=true)

Upvotes: 1

Related Questions