From dab424bfec3e9171bf2bab10a1b19da7d15aadab Mon Sep 17 00:00:00 2001 From: Giorgio Calderone Date: Tue, 28 Apr 2020 18:42:58 +0200 Subject: [PATCH] Updated --- docs/src/advanced.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/src/advanced.md b/docs/src/advanced.md index 5a1193a..88d31d0 100644 --- a/docs/src/advanced.md +++ b/docs/src/advanced.md @@ -255,6 +255,23 @@ saveas("advanced014e") # hide ![](assets/advanced014e.png) +The [`contourlines()`](@ref) function also allows to calculate the contour lines encompassing a given fraction of the total counts of a 2D histogram. E.g. to plot the contours corresponding to 1, 2, and 3 $\sigma$ of a 2D Gaussian distribution: +```@example abc +x = randn(10^5); +y = randn(10^5); +h = hist(x, y, nbins1=20, nbins2=20); + +# Calculate probability within 0 < r < σ +p(σ) = round(1 - exp(-(σ^2) / 2), sigdigits=3) + +# Draw contour lines at 1, 2 and 3 σ +clines = contourlines(h, p.(1:3)); +@gp palette(:beach, smooth=true, rev=true) "set grid front" "set size ratio -1" h clines +saveas("advanced014f") # hide +``` +![](assets/advanced014f.png) + + ## Animations The [Multiplot](@ref) capabilities can also be used to stack plots one above the other in order to create an animation, as in the following example: