# Normal probability plot

**URL:** https://discourse.julialang.org/t/normal-probability-plot/74663
**Category:** Visualization
**Tags:** statistics, distributions, statsplots
**Created:** [January 15, 2022, 11:40am UTC](https://discourse.julialang.org/t/normal-probability-plot/74663 "2022-01-15T11:40:05Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![iskyd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iskyd/32/44797_2.png) [@iskyd](https://discourse.julialang.org/u/iskyd)
#### Post date: [January 15, 2022, 11:40am UTC](https://discourse.julialang.org/t/normal-probability-plot/74663/1 "2022-01-15T11:40:05Z")

</div>

I have a dataframe that contains SalePrice and I’m trying to plot the normal distribution and the normal probability plot.

To plot the distribution I’m using Plots jl and StatsPlot and doing something like

```julia
histogram(train.SalePrice, normalize=true)
density!(train.SalePrice)

```

getting something like  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/8/7870af42ca9111a8a9cac88e8a8270eabdf58cf7.png)

I’m trying to plot also the normal distribution over that plot. Using python and seaborn you can simply do that:  
`sns.distplot(df_train['SalePrice'], fit=norm);`

![image](https://global.discourse-cdn.com/julialang/original/3X/2/1/218aafcc02d8eab7a3b1f918c05ed4b2a21e4617.png)

I’m also trying to plot the probability plot. In python i did  
`res = stats.probplot(df_train['SalePrice'], plot=plt)`  
getting something like this

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

So, is there a way in Julia to obtain the same thing?  
Thanks.

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [January 15, 2022, 11:46am UTC](https://discourse.julialang.org/t/normal-probability-plot/74663/2 "2022-01-15T11:46:44Z")

</div>

Have a look at `qqplot` in StatsPlots.jl  
[https://github.com/JuliaPlots/StatsPlots.jl#quantile-quantile-plots](https://github.com/JuliaPlots/StatsPlots.jl#quantile-quantile-plots)

---

<div class="post-metadata">

### Author: ![iskyd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iskyd/32/44797_2.png) [@iskyd](https://discourse.julialang.org/u/iskyd)
#### Post date: [January 15, 2022, 12:17pm UTC](https://discourse.julialang.org/t/normal-probability-plot/74663/3 "2022-01-15T12:17:25Z")

</div>

Thanks qqplot is exactly what i was looking for.

Any way to plot the normal distribution over the normalized histogram? Thanks.

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [January 15, 2022, 12:31pm UTC](https://discourse.julialang.org/t/normal-probability-plot/74663/4 "2022-01-15T12:31:37Z")

</div>

I’m no sure if Plots.jl allows you to determine the z-order of lines and areas, but you can always make the histogram semi transparent with the `alpha` keyword

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [January 15, 2022, 12:35pm UTC](https://discourse.julialang.org/t/normal-probability-plot/74663/5 "2022-01-15T12:35:30Z")

</div>

I misunderstood the question, you can

```julia
using Distributions
plot(Normal(mu, sigma))

```

To plot a distribution

---

<div class="post-metadata">

### Author: ![iskyd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iskyd/32/44797_2.png) [@iskyd](https://discourse.julialang.org/u/iskyd)
#### Post date: [January 15, 2022, 5:58pm UTC](https://discourse.julialang.org/t/normal-probability-plot/74663/6 "2022-01-15T17:58:59Z")

</div>

I’m trying something like that

```julia
histogram(train.SalePrice, normalize=true)
density!(train.SalePrice)
plot!(Normal(mean(train.SalePrice), var(train.SalePrice)))

```

I get this

![image](https://global.discourse-cdn.com/julialang/original/3X/1/0/1069614aa9ab11cacedef129a4560e9fa21b6316.png)

But it doesn’t seems right. I’m expecting this result

![image](https://global.discourse-cdn.com/julialang/original/3X/6/4/64ba6b4e0c9f52aa186d954c2fd74ca48c57f8ba.png)

Also tried using only mean without the variance and get this:

![image](https://global.discourse-cdn.com/julialang/original/3X/7/f/7f9e8b2bb2c5779f3b2746dd939b01d6770bc2a8.png)

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [January 15, 2022, 6:28pm UTC](https://discourse.julialang.org/t/normal-probability-plot/74663/7 "2022-01-15T18:28:33Z")

</div>

> [@iskyd](#):
>
> `plot!(Normal(mean(train.SalePrice), var(train.SalePrice)))`

You need to use `std` instead of `var.`

---

<div class="post-metadata">

### Author: ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)
#### Post date: [January 16, 2022, 12:54am UTC](https://discourse.julialang.org/t/normal-probability-plot/74663/8 "2022-01-16T00:54:36Z")

</div>

> [@Christopher\_Fisher](#):
>
> You need to use `std` instead of `var.`

Indeed, in standard notation \sigma (the standard-deviation sigma) is the square-root of the variance you computed.
