# Julia - How to plot a histogram with density as the vertical axis (中怎么绘制密度为纵轴的直方图)

**URL:** <https://discourse.julialang.org/t/julia-how-to-plot-a-histogram-with-density-as-the-vertical-axis/78149>\
**Category:** General Usage\
**Tags:** question, plotting\
**Created:** [March 20, 2022, 2:39am UTC](https://discourse.julialang.org/t/julia-how-to-plot-a-histogram-with-density-as-the-vertical-axis/78149 "2022-03-20T02:39:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yanjj1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yanjj1/32/47727_2.png) [@Yanjj1](https://discourse.julialang.org/u/Yanjj1)\
**Post date:** [March 20, 2022, 2:39am UTC](https://discourse.julialang.org/t/julia-how-to-plot-a-histogram-with-density-as-the-vertical-axis/78149/1 "2022-03-20T02:39:44Z")

</div>

1、julia怎么绘制直方图，纵轴为密度，然后拟合密度曲线  
2、julia怎么绘制正态分布曲线？  
3.或者julia对于r里的ggplot的…density…会无法识别要怎么修改？以下是我的r代码  
ggplot(data, aes\_string(x=“V5”)) +  
geom\_histogram(aes(y=…density…), # 这一步很重要,使用density代替y轴  
binwidth=1,  
colour=“black”, fill=“white”)  
4、julia怎么用ggplot画正态分布曲线

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [March 20, 2022, 3:27am UTC](https://discourse.julialang.org/t/julia-how-to-plot-a-histogram-with-density-as-the-vertical-axis/78149/2 "2022-03-20T03:27:10Z")

</div>

you may wanna try asking your question over at: [https://discourse.juliacn.com/](https://discourse.juliacn.com/)

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [March 20, 2022, 3:56am UTC](https://discourse.julialang.org/t/julia-how-to-plot-a-histogram-with-density-as-the-vertical-axis/78149/3 "2022-03-20T03:56:03Z")

</div>

Google Translate says

> 1. How to draw a histogram in julia, the vertical axis is density, and then fit the density curve
> 2. How does julia draw a normal distribution curve?
> 3. Or how to modify julia for ggplot in r…density…will not recognize how to modify it? Below is my r code  
> ggplot(data, aes\_string(x=“V5”)) +  
> geom\_histogram(aes(y=…density…), # This step is very important, use density instead of y axis  
> binwidth=1,  
> colour=“black”, fill=“white”)
> 4. How to use ggplot to draw a normal distribution curve in julia

I would suggest

[https://juliaplots.org/AlgebraOfGraphics.jl/dev/generated/analyses/#Density](https://juliaplots.org/AlgebraOfGraphics.jl/dev/generated/analyses/#Density)

[https://makie.juliaplots.org/stable/examples/plotting\_functions/density/](https://makie.juliaplots.org/stable/examples/plotting_functions/density/)
