# Plots: How to create a histogram such that sum of bar heights =1

**URL:** https://discourse.julialang.org/t/plots-how-to-create-a-histogram-such-that-sum-of-bar-heights-1/5392
**Category:** Visualization
**Created:** [August 15, 2017, 6:58pm UTC](https://discourse.julialang.org/t/plots-how-to-create-a-histogram-such-that-sum-of-bar-heights-1/5392 "2017-08-15T18:58:53Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [August 16, 2017, 3:10pm UTC](https://discourse.julialang.org/t/plots-how-to-create-a-histogram-such-that-sum-of-bar-heights-1/5392/21 "2017-08-16T15:10:02Z")

</div>

Great, that was my suggestion 1 here [Plots: How to create a histogram such that sum of bar heights =1 - #15 by mkborregaard](https://discourse.julialang.org/t/plots-how-to-create-a-histogram-such-that-sum-of-bar-heights-1/5392/15)  
I prefer this workaround.

---

<div class="post-metadata">

### Author: ![Seth\_Chandler](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Seth\_Chandler](https://discourse.julialang.org/u/Seth_Chandler)
#### Post date: [August 22, 2017, 1:00pm UTC](https://discourse.julialang.org/t/plots-how-to-create-a-histogram-such-that-sum-of-bar-heights-1/5392/22 "2017-08-22T13:00:32Z")

</div>

Two more plugs for more flexible normalization options within histogram. (And I know these are not the world’s strongest arguments, but …)

1. [Matlab does it](https://www.mathworks.com/help/matlab/ref/histogram.html?requestedDomain=www.mathworks.com). ‘Normalization’ with a valid option (‘count’, ‘probability’, ‘countdensity’, ‘pdf’, ‘cumcount’, or ‘cdf’)
2. [Wikipedia](https://en.wikipedia.org/wiki/Histogram) says it’s fine. “A histogram may also be normalized to display “relative” frequencies. It then shows the proportion of cases that fall into each of several categories, with the sum of the heights equaling 1.  
However, bins need not be of equal width; in that case, the erected rectangle is defined to have its area proportional to the frequency of cases in the bin. The vertical axis is then not the frequency but frequency density — the number of cases per unit of the variable on the horizontal axis.”

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [August 22, 2017, 1:19pm UTC](https://discourse.julialang.org/t/plots-how-to-create-a-histogram-such-that-sum-of-bar-heights-1/5392/23 "2017-08-22T13:19:32Z")

</div>

Hey, the best place to make those arguments would be on the open StatsBase PR.

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [August 23, 2017, 5:47pm UTC](https://discourse.julialang.org/t/plots-how-to-create-a-histogram-such-that-sum-of-bar-heights-1/5392/24 "2017-08-23T17:47:22Z")

</div>

UPDATE: The StatsBase PR got merged, which means that from the next release (or on StatsBase master), you can now simply plot this type of histogram with Plots using `histogram([6,6,6,6,7,7,7,7,7,8], normalize = :probability)`.

Welcome to the wonderful world of Open Source development, @Seth_Chandler 🙂

[Previous page](https://discourse.julialang.org/t/plots-how-to-create-a-histogram-such-that-sum-of-bar-heights-1/5392.md?page=1)
