Skip to content

Commit

Permalink
restore v0.4 behavior on v0.5, fixes #880
Browse files Browse the repository at this point in the history
also add test for histogram with density=true
  • Loading branch information
tlnagy committed Aug 24, 2016
1 parent 4a36837 commit b9e8975
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function apply_statistic(stat::HistogramStatistic,
x_min = Gadfly.concrete_minimum(values)
span = x_max - x_min
binwidth = span / d
bincounts ./= sum(bincounts) * binwidth
bincounts = bincounts ./ sum(bincounts) * binwidth
end

binwidth = (x_max - x_min) / d
Expand Down Expand Up @@ -384,7 +384,7 @@ function apply_statistic(stat::HistogramStatistic,

if stat.density
binwidth = x_span / d
bincounts ./= sum(bincounts) * binwidth
bincounts = bincounts ./ sum(bincounts) * binwidth
end

stack_height += bincounts[1:d]
Expand Down
5 changes: 5 additions & 0 deletions test/histogram_density.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Gadfly, RDatasets

# see issue #880
plot(dataset("ggplot2", "diamonds"), x="Price", color="Cut",
Geom.histogram(bincount=30, density=true))

0 comments on commit b9e8975

Please sign in to comment.