Skip to content

Commit

Permalink
Fix discrete histogram bin count heuristic for non-integer data. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dcjones committed Sep 26, 2014
1 parent b1d3374 commit da1669b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
julia 0.3-
Codecs
Color 0.3.4
Compose 0.3.8
Compose 0.3.9
Contour
DataFrames 0.4.2
DataStructures
Expand Down
5 changes: 3 additions & 2 deletions src/bincount.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ function choose_bin_count_1d_discrete(xs::AbstractArray, xs_set::AbstractArray,

# minimum distance between two values
mingap = zero(eltype(xs))
for (a, b) in zip(1:length(xs_set)-1, 2:length(xs_set))
mingap = mingap == zero(eltype(xs)) ? b - a : min(b - a, mingap)
for (i, j) in zip(1:length(xs_set)-1, 2:length(xs_set))
a, b = xs[i], xs[j]
mingap = mingap == zero(eltype(xs)) ? abs(b - a) : min(abs(b - a), mingap)
end

x_min, x_max = Gadfly.concrete_minimum(xs), Gadfly.concrete_maximum(xs)
Expand Down
1 change: 0 additions & 1 deletion src/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ function apply_statistic(stat::HistogramStatistic,
value_set = collect(Set(values[Bool[Gadfly.isconcrete(v) for v in values]]))
sort!(value_set)


if length(value_set) / length(values) < 0.9
d, bincounts, x_max = choose_bin_count_1d_discrete(
values, value_set, stat.minbincount, stat.maxbincount)
Expand Down

0 comments on commit da1669b

Please sign in to comment.