Julia: marker_z takes much time

Viewed 115

I'm trying to do a gradation plotting.

using Plots
using LinearAlgebra

L = 60 #size of a matrix
N = 10000 #number of loops

E = zeros(Complex{Float64},N,L) #set of eigenvalues
IPR = zeros(Complex{Float64},N,L) #indicator for marker_z

Preparing E & IPR

function main() 

cnt = 0 
    
for i = 1:N
    cnt += 1
    H = rand(Complex{Float64},L,L) 
    eigenvalue,eigenvector = eigen(H)
    
        for j = 1:L
            E[cnt,j] = eigenvalue[j] 
            IPR[cnt,j] = abs2(norm(abs2.(eigenvector[:,j])))/(abs2(norm(eigenvector[:,j])))
        end

end

end

Plotting

function main1()

plot(real.(E),imag.(E),marker_z = real.(IPR),st = scatter,markercolors=:cool,markerstrokewidth=0,markersize=1,dpi=300) 
plot!(legend=false,xlabel="ReE",ylabel="ImE") 
savefig("test.png")
    
end

@time main1()

358.794885 seconds (94.30 M allocations: 129.882 GiB, 2.05% gc time)

Comparing with a uniform plotting, a gradation plotting takes too much time.

function main2()

plot(real.(E),imag.(E),st = scatter,markercolor=:blue,markerstrokewidth=0,markersize=1,dpi=300) 
plot!(legend=false,xlabel="ReE",ylabel="ImE") 
savefig("test1.png")
    
end

@time main2()

8.100609 seconds (10.85 M allocations: 508.054 MiB, 0.47% gc time)

Is there a way of gradation plotting as fast as a uniform plotting?

1 Answers

I solved the problem by myself.
After updating from Julia 1.3.1 to Julia1.6.3, I checked the main1 became faster as Bill's comments.

Related