Plotting two different functions

Hello, there! I’m trying to plot two different functions at the same graph, using Plots.jl, as follows

Pkg.add("Plots")
using Plots

p(s) = s/2 * exp(-s^2/4)

g(s) = exp(-s)

plot(p,g)

but I receive the error message

>AssertionError: !(F2 <: Function || F2 <: AbstractArray && F2.parameters[1] <: Function)

There is an error at my syntaxe or I can not do it with Plots.jl?

What range do you want to plot them over?

You could do something like

p = plot(0.0:0.01:1.0, p)
plot!(p, 0.0:0.01:1.0, g)
1 Like

Plotting from s=0 to s=10 would be enough.

Did the following:

p(s) = s/2 * exp(-s^2/4)

g(s) = exp(-s)

plot(p,xlimit=(0,10))
plot!(g,xlimit=(0,10))

and it worked! Thank you very much!

2 Likes