Vautrin Balzac
Vautrin Balzac

Reputation: 55

Plotting heatmap of a correlation matrix using Julia

I would like to plot a heatmap of the following kind of matrix.

Matrix to plot

The final output should look like this: Expected output style

Thanks very much!

Upvotes: 4

Views: 1585

Answers (2)

Stepan S. Sushko
Stepan S. Sushko

Reputation: 1368

I would suggest

using PlotlyJS
z = convert(Matrix{Float64}, z)
plot( heatmap(z=z))

Upvotes: 2

Benoit Pasquier
Benoit Pasquier

Reputation: 2995

Have you tried the heatmap function from a plotting package, e.g., Plots.jl?

julia> using Plots, LinearAlgebra

julia> M = min.(1.0, Matrix(Symmetric(rand(5,5) + I)))
5×5 Matrix{Float64}:
 1.0        0.737985  0.0273955  0.199343  0.0553962
 0.737985   1.0       0.604142   0.576031  0.785242
 0.0273955  0.604142  1.0        0.854256  0.389215
 0.199343   0.576031  0.854256   1.0       0.327517
 0.0553962  0.785242  0.389215   0.327517  1.0

julia> heatmap(M, yflip=true)

gives

enter image description here

Upvotes: 3

Related Questions