# 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:** 1\
**Showing post:** 15

<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, 11:55am UTC](https://discourse.julialang.org/t/plots-how-to-create-a-histogram-such-that-sum-of-bar-heights-1/5392/15 "2017-08-16T11:55:51Z")

</div>

We could consider taking the discussion in a Plots issue?

Anyway, until a new keyword is in place, the easiest approach is either to use @stevengj 's PyPlot method or to do a Plots workaround, either

1. by fitting a StatsBase histogram, modifying the `weights` field and passing to `plot` (there is a recipe for that)
2. plotting the histogram as normal and specifying different `yticks` or
3. doing something hacky with modifying the plot object:

```julia
function prophist(x; kw...)
    s = length(x)
    h = histogram(x; kw...)
    h[1][1][:y] ./= s
    h[1][:yaxis].d[:extrema].emax /= s #also change the ylimits
    h
end

prophist(randn(10000), bins = :scott)

```

---

_[View the full topic](https://discourse.julialang.org/t/plots-how-to-create-a-histogram-such-that-sum-of-bar-heights-1/5392)._
