由于this answer for a related question in Python,我编写了一些Julia代码以在for循环中显示直方图。
id: 2, category: Grape, unit price: 8, qty: 6, total price: 48.0
要创建using PyPlot
γvec = 0.1:0.1:0.9 # γ : fixed paramter
N = 1000 # N : number of samples for each γ
fig, axs = subplots(length(γvec), 1, figsize=(10, 6.18*length(γvec)), constrained_layout=true)
fig.suptitle("Distribution of eigenvalues of ρ at final time", fontsize=20, y=1)
# TL;DR
λ₁vec, λ₂vec = zeros(Complex{Float64}, N), zeros(Complex{Float64}, N);
for (iᵧ, γ) in enumerate(γvec)
# println(γ)
samples = [ myfunction(...) for _ in 1:N ]; # draw samples
for i in 1:N
λ₁₂ = eigvals(samples[i][1]) # calculate (real-valued) eigenvalues of ρ
λ₁vec[i], λ₂vec[i] = maximum(real(λ₁₂)), minimum(real(λ₁₂))
end
axs[iᵧ].hist(λ₁vec) # plot histogram of eigenvalues of ρ
axs[iᵧ].hist(λ₂vec)
axs[iᵧ].set_title("γ = $γ")
axs[iᵧ].set_xlabel("eigenvalues of ρ")
end
gcf() # get current figure
,我从another answer开始采用了语法,并读了an e-book's sample code on GitHub。这是我做的图。
茱莉亚的PyPlot产生的标题和副标题重叠。如何正确显示标题和字幕?
根据评论进行了编辑。
我正在使用最新版本的Juno和Julia。