plot - 朱莉娅:marker_z 需要很多时间
问题描述
我正在尝试进行渐变绘图。
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
准备电子和知识产权
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
绘图
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)
与均匀绘图相比,渐变绘图需要太多时间。
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)
有没有一种像均匀绘图一样快的渐变绘图方法?
解决方案
我自己解决了这个问题。
从 Julia 1.3.1 更新到 Julia1.6.3 后,我检查了 main1 随着比尔的评论变得更快。
推荐阅读
- sql - SQL Server:仅当同一个表中的另一列是特定值时,如何强制一列中的 NOT NULL?
- c++ - 如何在 4x4 数组中随机选择 3 个不同的位置
- java - 我怎样才能更好地将我的用户输入法调用到我的主要方法中,以检查获胜条件?
- hbase - HBASE - 增量和增量列值无法在分布式设置中增加计数器
- java - Intellij Idea 评论错误
- php - DATE_ADD(NOW(), INTERVAL 5 MINUTE 插入
- ruby-on-rails - Ruby 中的领域特定语言和翻译
- r - R:函数内部 ggplot 的无法解释的行为
- reactjs - 在 react-chartjs-2 中将背景颜色更改为渐变
- c# - 如果项目存在于 C#/WPF 的 ObservableCollection 中,则查找数字的索引