Overlay Normal distribution on density or histogram plot

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

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.

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.

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.