# An illustration of Julia's beautiful design via truncated normal plots using StatsPlot.jl and Distributions.jl

**URL:** <https://discourse.julialang.org/t/an-illustration-of-julias-beautiful-design-via-truncated-normal-plots-using-statsplot-jl-and-distributions-jl/8876>\
**Category:** Visualization\
**Created:** [February 6, 2018, 10:58pm UTC](https://discourse.julialang.org/t/an-illustration-of-julias-beautiful-design-via-truncated-normal-plots-using-statsplot-jl-and-distributions-jl/8876 "2018-02-06T22:58:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [February 6, 2018, 10:58pm UTC](https://discourse.julialang.org/t/an-illustration-of-julias-beautiful-design-via-truncated-normal-plots-using-statsplot-jl-and-distributions-jl/8876/1 "2018-02-06T22:58:10Z")

</div>

I was going to give a talk on a topic involving truncated normal distributions and I decided to write it in Julia. I googled how to do a density plot and quickly found an example for plotting the density of a normal function

```julia
using StatPlots
using Distributions
plot(Normal(3,5), fill=(0, .5,:orange))

```

Great. But how do I do a truncated one? I search for truncated normal and found it in Distributions.jl with a beautifully simple API `Truncated(d, l, u)`, so I did

```julia
plot(Truncated(Normal(0,1), -1, 1.2), fill=(0, .5,:orange), xlim = (-2,2))

```

and viola!

 ![Capture](https://global.discourse-cdn.com/julialang/original/3X/3/c/3c73d134f9438f1a8313431e7ca82fbba4fe60b5.png)

I remember doing this in R and I don’t remember it as this easy! And R is by statisticians for statisticians!

I think this is a great illustration of the expressive power of Julia as a language and, in particular, for general statistical work!
