Error in legend

Dear all,
I have a litte problem in plot a graph using a layout: I would like each legend in each graph, but this not happen, as we can see:

using DifferentialEquations
using Plots
plotly()

function SIR!(du,u,p,t)
    du[1] = -p[1]*u[1]*u[2]                  
    du[2] = p[1]*u[1]*u[2] - p[2]*u[2]
    du[3] = p[2]*u[2]
end
p = [0.8;0.2]
u0 = [0.9;0.1;0.0]   
tspan = (0.0,50.0)    

prob = ODEProblem(SIR!,u0,tspan,p)
sol = solve(prob)

plot(sol,linewidth=2,xaxis="t",layout=(3,1),color=["red" "green" "blue"],label=["S(t)" "I(t)" "R(t)"])

Anyone can help me please?
SIR

I think it is easier to plot separately:

plot(layout=(3,1))
plot!(sol[:,1],color="red",label="S(t)",subplot=1)
plot!(sol[:,2],color="green",label="I(t)",subplot=2)
plot!(sol[:,3],color="blue",label="R(t)",subplot=3,xlabel="t")

(I am guessing the structure of the “sol” data here)

1 Like