# Normalized densities in Gadfly

**URL:** <https://discourse.julialang.org/t/normalized-densities-in-gadfly/49141>\
**Category:** Visualization\
**Tags:** question, gadfly\
**Created:** [October 27, 2020, 7:03pm UTC](https://discourse.julialang.org/t/normalized-densities-in-gadfly/49141 "2020-10-27T19:03:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yarnton](https://avatars.discourse-cdn.com/v4/letter/y/ac91a4/32.png) [@yarnton](https://discourse.julialang.org/u/yarnton)\
**Post date:** [October 27, 2020, 7:03pm UTC](https://discourse.julialang.org/t/normalized-densities-in-gadfly/49141/1 "2020-10-27T19:03:34Z")

</div>

As a newcomer I’ve found Gadfly very easy to learn and elegant to use.

I encountered a little issue. A simple `Geom.density` seems to be non-normalized. That is, to be a function of frequencies, not probabilities.

@tlnagy is it possible to draw normalized densities? Is it perhaps implemented in the development branch of Gadfly already? I couldn’t find the appropriate parameter, although I could see some potentially related issues.

Thanks.

---

<div class="post-metadata">

**Author:** ![tlnagy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlnagy/32/5815_2.png) [@tlnagy](https://discourse.julialang.org/u/tlnagy)\
**Post date:** [October 27, 2020, 7:40pm UTC](https://discourse.julialang.org/t/normalized-densities-in-gadfly/49141/2 "2020-10-27T19:40:07Z")

</div>

Glad you’re enjoying Gadfly!

Just to clarify, what do you mean by normalized densities? By default, Gadfly normalizes density plots to have an area under the curve (AUC) equal to 1.0. So I suspect that you have `x` values greater than 1 and that’s why you’re getting low values for `y` since AUC=1.

The implementation is quite simple and just calls `KernelDensity.jl` under the hood here:

[https://github.com/GiovineItalia/Gadfly.jl/blob/d507b208cab7da3dfd9104ada3a3d2281ef5646c/src/statistics.jl#L563-L565](https://github.com/GiovineItalia/Gadfly.jl/blob/d507b208cab7da3dfd9104ada3a3d2281ef5646c/src/statistics.jl#L563-L565)

Does that help?
