# How to draw histogram of a sine?

**URL:** <https://discourse.julialang.org/t/how-to-draw-histogram-of-a-sine/81361>\
**Category:** General Usage\
**Tags:** plotting, plots, histogram\
**Created:** [May 20, 2022, 12:12pm UTC](https://discourse.julialang.org/t/how-to-draw-histogram-of-a-sine/81361 "2022-05-20T12:12:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![youxiuqingnianyyy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/youxiuqingnianyyy/32/36421_2.png) [@youxiuqingnianyyy](https://discourse.julialang.org/u/youxiuqingnianyyy)\
**Post date:** [May 20, 2022, 12:12pm UTC](https://discourse.julialang.org/t/how-to-draw-histogram-of-a-sine/81361/1 "2022-05-20T12:12:02Z")

</div>

![微信图片_20220520135556](https://global.discourse-cdn.com/julialang/original/3X/a/3/a3baf7c361c3edcb3b467dcce594c0183f7c2954.jpeg)  
I want to draw the figure like this in Julia Plots. Is there any package I could use? Need suggestion.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [May 20, 2022, 12:41pm UTC](https://discourse.julialang.org/t/how-to-draw-histogram-of-a-sine/81361/2 "2022-05-20T12:41:40Z")

</div>

One example using `Plots.jl` and `Distributions.jl`:

```julia
using Plots, Distributions
x = 0:0.01:100
y1 = sin.(x)
y2 = rand(Normal(0,0.3),length(x))
p1 = plot(x, y1)
p2 = histogram(y1, nbins=-1:0.1:1)
p3 = plot(x, y2)
p4 = histogram(y2, nbins=-1:0.1:1)
plot(p1,p3,p2,p4, layout=(2,2))

```

---

<div class="post-metadata">

**Author:** ![youxiuqingnianyyy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/youxiuqingnianyyy/32/36421_2.png) [@youxiuqingnianyyy](https://discourse.julialang.org/u/youxiuqingnianyyy)\
**Post date:** [May 20, 2022, 1:32pm UTC](https://discourse.julialang.org/t/how-to-draw-histogram-of-a-sine/81361/4 "2022-05-20T13:32:10Z")

</div>

It helps a lot. Thanks
