Hi to everybody,
I am trying to make some plots for my research (Fisher contour plots) using Plots.jl. I am quite satisfied with the results I have obtained (in a very short amount of time!)
FisherMatrix = [16523.02 3319.2230;3319.2230 711.09] #Fisher matrix used in the MWE
CovarianceMatrix = inv(FisherMatrix)
σw0 = sqrt(CovarianceMatrix[1,1])
σwa = sqrt(CovarianceMatrix[2,2])
σw0wa = (CovarianceMatrix[1,2])
plot_font = "Computer Modern"
Plots.default(titlefont = (16, plot_font), fontfamily=plot_font, linewidth=1, framestyle=:box, fg_legend =:black, label=nothing, grid=false, tickfontsize=12, size = (600, 500), labelfontsize = 15, dpi = 100)
#Needed for normalization
function gaussian(μ::Float64, σ::Float64, x)
return 1/(sqrt(2π*σ^2))*exp(-0.5*(x-μ)^2/σ^2)
end
#Drawing ellipses
t = LinRange(0,2π, 200)
θ = 0.01*atan(2σw0wa/(σw0^2-σwa^2))/2#the 0.0
a = (σw0^2+σwa^2)/2+sqrt(((σw0^2-σwa^2)^2)/4+σw0wa^2)
b = (σw0^2+σwa^2)/2-sqrt(((σw0^2-σwa^2)^2)/4+σw0wa^2)
x = a .* cos.(θ) .* cos.(t) - b .* sin.(θ) .* sin.(t)
y = a .* sin.(θ) .* cos.(t) + b .* cos.(θ) .* sin.(t)
p_ell = Plots.plot(x, y, linewidth = 1, legend = false, fill = (0, 0.5, :red),color="red")
Plots.plot!(3x, 3y, linewidth = 1, legend = false, fill = (0, 0.5, :red), xticks = round.(range(-3a,stop=3a,length = 3),digits=2), yticks = round.(range(-3b,stop=3b,length = 3),digits=4), xlim=(-4a,4a), ylim=(-4b,4b), color="red", ylabel = L"w_a", xlabel = L"w_0")
x = Array(LinRange(-4a,4a, 200))
pwa = Plots.plot(x, gaussian.(0., a, x)./gaussian.(0., a, 0), fill=(0, .5,:red), legend = false, xticks = round.(range(-3a,stop=3a,length = 3),digits=2), yticks = round.(range(0,stop=1,length=2),digits=2), color="red")
x = Array(LinRange(-a,a, 200))
Plots.plot!(pwa, x, gaussian.(0., a, x)./gaussian.(0., a, 0), fill=(0, .5,:red), legend = false, xticks = round.(range(-3a,stop=3a,length = 3),digits=2), yticks = round.(range(0,stop=1,length=2),digits=2), color="red", ylabel = L"w_0")
x = Array(LinRange(-4b,4b, 200))
pw0 = Plots.plot(x, gaussian.(0., b, x) ./gaussian.(0., b, 0.), fill=(0, .5,:red), legend = false, xticks = round.(range(-3b,stop=3b,length = 3),digits=4), yticks = round.(range(0,stop=1,length = 2)),figsize=(10,10), color="red")
x = Array(LinRange(-b,b, 200))
Plots.plot!(pw0, x, gaussian.(0., b, x) ./gaussian.(0., b, 0.), fill=(0, .5,:red), legend = false, xticks = round.(range(-3b,stop=3b,length = 3),digits=4), yticks = round.(range(0,stop=1,length = 2)),figsize=(10,10), color="red", xlabel = L"w_a", ymirror=true,)
p_contour = Plots.plot(pwa, emptyplot(), p_ell, pw0, layout = (2, 2), link =:both)
The result is nice, but I would like to add a couple of things.
- Whitespace: can I reduce/remove the white space between the subplots?
- Legend: I’d like to set a single legend for all the plots (possibly in the top right corner)
I’d like to obtain something such as this, obtained with matplotlib
Do youhave any suggestion? Any other Julia plot library I could use?
Best regards,
Marco