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

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:
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)