# Plotting a distribution

**URL:** <https://discourse.julialang.org/t/plotting-a-distribution/25356>\
**Category:** Statistics\
**Created:** [June 17, 2019, 6:17am UTC](https://discourse.julialang.org/t/plotting-a-distribution/25356 "2019-06-17T06:17:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![stene](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stene/32/26044_2.png) [@stene](https://discourse.julialang.org/u/stene)\
**Post date:** [June 17, 2019, 6:17am UTC](https://discourse.julialang.org/t/plotting-a-distribution/25356/1 "2019-06-17T06:17:38Z")

</div>

Trying to plot normal distributions from the Distributions package. How do I do this?

**julia\>** normalDist = fit(Normal, data)

Normal{Float64}(μ=100.3434334, σ=0.05)

**julia\>** plot(normalDist)

**ERROR:** No user recipe defined for Normal{Float64}

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [June 17, 2019, 6:25am UTC](https://discourse.julialang.org/t/plotting-a-distribution/25356/2 "2019-06-17T06:25:52Z")

</div>

Which plotting package is this? Try `StatsPlots` [https://github.com/JuliaPlots/StatsPlots.jl/blob/master/README.md](https://github.com/JuliaPlots/StatsPlots.jl/blob/master/README.md)

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 17, 2019, 6:33am UTC](https://discourse.julialang.org/t/plotting-a-distribution/25356/3 "2019-06-17T06:33:28Z")

</div>

Please [quote your code](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530).

It is unclear _what_ you want to plot for a distribution. The pdf, the cdf, or something else? In any case, here is a PGFPlotsX example:

```julia
using PGFPlotsX, Distributions

d = Normal(100.3434334, 0.05)
lo, hi = quantile.(d, [0.01, 0.99])
x = range(lo, hi; length = 100)
@pgf Axis({ xlabel = "x", ylabel = "pdf" },
          Plot({thick, blue }, Table(x, pdf.(d, x))))
@pgf Axis({ xlabel = "x", ylabel = "cdf" },
          Plot({thick, blue }, Table(x, cdf.(d, x))))

```

 ![1](https://global.discourse-cdn.com/julialang/original/3X/6/6/66302b59835bc97f073b71897840d4f58eca8ca3.png)

 ![2](https://global.discourse-cdn.com/julialang/original/3X/8/b/8b8842894951d8e01ad0b7a55c3b4cb597c35bfc.png)

---

<div class="post-metadata">

**Author:** ![stene](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stene/32/26044_2.png) [@stene](https://discourse.julialang.org/u/stene)\
**Post date:** [June 17, 2019, 8:27pm UTC](https://discourse.julialang.org/t/plotting-a-distribution/25356/4 "2019-06-17T20:27:46Z")

</div>

Thank You! StatsPlots works as expected. I was trying the standard Plots package.

---

<div class="post-metadata">

**Author:** ![FelipePKest](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/felipepkest/32/31245_2.png) [@FelipePKest](https://discourse.julialang.org/u/FelipePKest)\
**Post date:** [December 1, 2021, 4:00am UTC](https://discourse.julialang.org/t/plotting-a-distribution/25356/5 "2021-12-01T04:00:13Z")

</div>

Hi, don’t know if there’s still any trouble on this, but you can plot a distribuition using the normal Plots package now. You only have to declare a plot() variable and call it using the distribuition as a parameter. Ex:  
p = Plots.plot()  
Plots.plot!(p,Geometric(0.6))

---

<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:** [December 1, 2021, 9:43am UTC](https://discourse.julialang.org/t/plotting-a-distribution/25356/6 "2021-12-01T09:43:50Z")

</div>

> [@FelipePKest](#):
>
> but you can plot a distribuition using the normal Plots package now.

Are you sure? Using latest Plots.jl version but still need to get the Distributions’ recipes from StatsPlots:

```julia
using StatsPlots, Distributions
plot(Geometric(0.6))

```

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [December 1, 2021, 10:04am UTC](https://discourse.julialang.org/t/plotting-a-distribution/25356/7 "2021-12-01T10:04:36Z")

</div>

Same for me on the latest Plots release:

```julia
(jl_P3u1qh) pkg> st
      Status `...\Temp\jl_P3u1qh\Project.toml`
  [31c24e10] Distributions v0.25.34
  [91a5bcdd] Plots v1.24.3

julia> using Plots, Distributions

julia> plot(Geometric(0.6))
ERROR: Cannot convert Geometric{Float64} to series data for plotting

```
