From 2d095daddc187dc09acc13ab8654a32bd8db7c7f Mon Sep 17 00:00:00 2001 From: Diego Javier Zea Date: Tue, 7 Jun 2016 23:44:41 -0300 Subject: [PATCH] Solve a bug with whisker lengths (#210) --- src/recipes.jl | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index cb2c7a0e..68db886d 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -483,16 +483,21 @@ notch_width(q2, q4, N) = 1.58 * (q4-q2)/sqrt(N) # internal nodes for notches L, R = center - 0.5 * _box_halfwidth, center + 0.5 * _box_halfwidth # outliers - limit = range*(q4-q2) - for value in values - if (value < (q2 - limit)) || (value > (q4 + limit)) - push!(outliers_y, value) - push!(outliers_x, center) + if Float64(range) != 0.0 # if the range is 0.0, the whiskers will extend to the data + limit = range*(q4-q2) + inside = Float64[] + for value in values + if (value < (q2 - limit)) || (value > (q4 + limit)) + push!(outliers_y, value) + push!(outliers_x, center) + else + push!(inside, value) + end end + # change q1 and q5 to show outliers + # using maximum and minimum values inside the limits + q1, q5 = extrema(inside) end - # change q1 and q5 to use the limit in order to show outliers - q1 = q2 - limit - q5 = q4 + limit # Box xcoords = notch::Bool ? [ m, l, r, m, m, NaN, # lower T