From fcb13c64ebb91b082abe94b70777be18821ba22d Mon Sep 17 00:00:00 2001 From: marius Date: Tue, 12 Sep 2023 02:16:47 -0700 Subject: [PATCH] add Plots.jl plotting of kde objects --- src/CMBLensing.jl | 6 +++--- src/plots.jl | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/CMBLensing.jl b/src/CMBLensing.jl index ca04cff9..eaaec89f 100644 --- a/src/CMBLensing.jl +++ b/src/CMBLensing.jl @@ -145,9 +145,6 @@ include("masking.jl") include("taylens.jl") include("bilinearlens.jl") -# plotting -include("plots.jl") - # PPL include("distributions.jl") include("simpleppl.jl") @@ -158,6 +155,9 @@ include("maximization.jl") include("sampling.jl") include("chains.jl") +# plotting +include("plots.jl") + # deprecated stuff include("deprecated.jl") diff --git a/src/plots.jl b/src/plots.jl index ac276402..f4dc9969 100644 --- a/src/plots.jl +++ b/src/plots.jl @@ -39,4 +39,24 @@ end @recipe function plot(Cℓ::Cℓs) (Cℓ.ℓ, Cℓ.Cℓ) +end + +@recipe function plot(k::GetDistKDE{2}; clevels=[0.95,0.68], filled=false) + + if filled + seriestype := :contourf + levels := [PyArray(k.kde.getContourLevels(clevels)); prevfloat(Inf)] + alpha := 0.5 + else + seriestype := :contour + levels := PyArray(k.kde.getContourLevels(clevels)) + end + cbar := false + + return PyArray(k.kde.x), PyArray(k.kde.y), PyArray(k.kde.P) + +end + +@recipe function plot(k::GetDistKDE{1}; transform=identity) + (PyArray(k.kde.x), transform.(PyArray(k.kde.P))) end \ No newline at end of file