# Overlay Normal distribution on density or histogram plot

**URL:** <https://discourse.julialang.org/t/overlay-normal-distribution-on-density-or-histogram-plot/67664>\
**Category:** General Usage\
**Tags:** question, plotting, makie\
**Created:** [September 3, 2021, 6:45pm UTC](https://discourse.julialang.org/t/overlay-normal-distribution-on-density-or-histogram-plot/67664 "2021-09-03T18:45:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [September 3, 2021, 6:45pm UTC](https://discourse.julialang.org/t/overlay-normal-distribution-on-density-or-histogram-plot/67664/1 "2021-09-03T18:45:50Z")

</div>

I’m trying out Makie and AlgebraOfGraphics. Very cool!

I’m wondering how to add a plot of a Normal distribution pdf over my `density` or `histogram` layer. For example, how could I add it as a third curve in this particular example from the docs? Normally I would just plot a new line, but I don’t quite see how to do that with this syntax where everything seems to be driven by the data.

[http://juliaplots.org/AlgebraOfGraphics.jl/dev/gallery/gallery/statistical%20analyses/density\_plots/#Density-plots](http://juliaplots.org/AlgebraOfGraphics.jl/dev/gallery/gallery/statistical%20analyses/density_plots/#Density-plots)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [September 3, 2021, 6:51pm UTC](https://discourse.julialang.org/t/overlay-normal-distribution-on-density-or-histogram-plot/67664/2 "2021-09-03T18:51:54Z")

</div>

One nice thing about AoG is that you can continue with normal Makie plotting after `draw`, in case what you want to do is difficult to set up using the dataframe like input.

I don’t know if AoG supports Distributions directly, though.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [September 3, 2021, 7:41pm UTC](https://discourse.julialang.org/t/overlay-normal-distribution-on-density-or-histogram-plot/67664/3 "2021-09-03T19:41:23Z")

</div>

Yes I saw that in the docs FAQ section but that section creates a new second plot, rather than updating the existing plot. It doesn’t need to support Distributions, I can make a function of the pdf.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [September 3, 2021, 8:32pm UTC](https://discourse.julialang.org/t/overlay-normal-distribution-on-density-or-histogram-plot/67664/4 "2021-09-03T20:32:24Z")

</div>

If your AoG plot has only one axis, doing something like `lines!(args...)` should just work. Otherwise you’d need to extract the axis you want to target from AoGs return object and pass it directly to the plotting function.
