From 24c27737c1b8ff816d394efe2f06c2d7c0512c54 Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Sun, 26 Feb 2017 08:32:52 +0100 Subject: [PATCH] fix uneven bins --- src/recipes.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/recipes.jl b/src/recipes.jl index 156bda3e..0585e488 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -410,6 +410,8 @@ function my_hist(v, bins; normed = false, weights = nothing) counts[idx] += (weights == nothing ? 1.0 : weights[i]) end + counts = isapprox(extrema(diff(edges))...) ? counts : counts ./ diff(edges) # for uneven bins, normalize to area. + # normalize by bar area? norm_denom = normed ? sum(diff(edges) .* counts) : 1.0 if norm_denom == 0 @@ -424,7 +426,8 @@ end edges, counts = my_hist(y, d[:bins], normed = d[:normalize], weights = d[:weights]) - x := edges + bar_width := diff(edges) + x := centers(edges) y := counts seriestype := :bar ()