I try to plot (ReE,ImE) graph, here E = Re[E] + iIm[E] are the complex eigenvalues of a matrix H.

However, in this code, the plotting is colored by some default color.
I want to plot each (ReE,ImE) by coloring with blue gradation according to the value of the norm of eigenvector of E.
What should I do?

My code is below:

eigenvalue,eigenvector = eigen(H)
plot(real.(eigenvalue),imag.(eigenvalue),st = scatter,markersize = 0.2)


thank you

This is not exactly what is requested but may be useful:

using LinearAlgebra, Plots; gr()
H = rand(-10:10,40,40)
eigenvalue,eigenvector = eigen(H)
ix = sortperm(abs.(eigenvalue))


NB: the colors are mapped to the sorted magnitudes and not proportionally to the magnitudes themselves…

1 Like

Here’s a solution using AlgebraOfGraphics:

using LinearAlgebra
using CairoMakie
using AlgebraOfGraphics

H = rand(-10:10, 40, 40)
λ, v = eigen(H)

draw(mapping([real(λ)] => "Re", [imag(λ)] => "Im", color=[abs.(λ)] => "Magnitude") *
visual(colormap=:blues),
axis=(width=300, height=200))


This is using the magnitude of the eigenvalues (the eigenvectors returned by eigen all have norm 1, and for every eigenvector \vec{v} and k\neq 0 the vector k\vec{v} is also an eigenvector so I’m not sure why you would want to plot the eigenvector norms?).

Edit: and with simple Makie:

using LinearAlgebra, CairoMakie

H = rand(-10:10, 40, 40)
λ, v = eigen(H)

scatter(real(λ), imag(λ), color=abs.(λ), colormap=:blues)

3 Likes

In Plots, use marker_z (or mz) to specify the value to map to marker color.

eigenvalue,eigenvector = eigen(H)
scatter(eigenvalue, marker_z = abs.(eigenvalue),
legend=false, cbar=true)


2 Likes

@yha, may use argument: color =:blues

1 Like

Note that H was made up and not by the OP.

But the same is true of any matrix: although not documented I think, eigen always returns normalized eigenvectors.

Well there’s probably a matrix type out there that specializes eigen and returns non-normalized vectors, but even so it seems like a detail of the implementation with no mathematical meaning…

You are right, it is the eigenvalues that give magnitude along each eigen direction.