# Plotting two distributions on same plot

**URL:** <https://discourse.julialang.org/t/plotting-two-distributions-on-same-plot/75475>\
**Category:** New to Julia\
**Tags:** distributions\
**Created:** [January 30, 2022, 8:45pm UTC](https://discourse.julialang.org/t/plotting-two-distributions-on-same-plot/75475 "2022-01-30T20:45:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CentraCep](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/centracep/32/32454_2.png) [@CentraCep](https://discourse.julialang.org/u/CentraCep)\
**Post date:** [January 30, 2022, 8:45pm UTC](https://discourse.julialang.org/t/plotting-two-distributions-on-same-plot/75475/1 "2022-01-30T20:45:46Z")

</div>

I am trying to plot two probability distributions onto the same plot. One is a _uniform distribution_ with area under the curve = 1 and the other is a _chi distribution_ (or to be more specific, a Maxwellian) with three degrees of freedom with area under the curve = 1. Here is my code so far:

```julia
using Plots, Distributions
gr()

v = -0.5:0.001:1.5
f_s0 = pdf.(Uniform(0,1), v) # uniform distribution with area 1
F_s = pdf.(Chi(3), v) # chi distribution with area 1

plot(v, f_s0, label="f_s0")
plot!(v, F_s, linecolor = :orange, linestyle = :dash, label="F_s (Maxwellian)")
xlabel!("velocity")
ylabel!("probability density")
xlims!(-0.5, 1.5)
ylims!(0, 1.5)

```

When I run this, I get

```julia
DomainError with -0.5:
log will only return a complex result if called with a complex argument. Try log(Complex(x)).

```

Any suggestions?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [January 30, 2022, 9:13pm UTC](https://discourse.julialang.org/t/plotting-two-distributions-on-same-plot/75475/3 "2022-01-30T21:13:56Z")

</div>

Looks like a bug. See issue filed [here](https://github.com/JuliaStats/Distributions.jl/issues/1497) and PR [here](https://github.com/JuliaStats/Distributions.jl/pull/1498)
