Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting heatmap of a correlation matrix using Julia

Tags:

plot

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!

like image 629
Vautrin Balzac Avatar asked Oct 21 '25 16:10

Vautrin Balzac


2 Answers

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

like image 172
Benoit Pasquier Avatar answered Oct 24 '25 21:10

Benoit Pasquier


I would suggest

using PlotlyJS
z = convert(Matrix{Float64}, z)
plot( heatmap(z=z))
like image 41
Stepan S. Sushko Avatar answered Oct 24 '25 21:10

Stepan S. Sushko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!