I'm trying to add_trace ad each loop, but I get only one plot with multiplies lines on over each other.
mean <- -0.0007200342
sd <- 0.3403711
N=10
T=1
Delta = T/N
W = c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd)))
t <- seq(0,T, length=N+1)
p<-plot_ly(y=W, x=t)
for(i in 1:5){
W <- c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd)))
p<-add_trace(p, y=W)
}
print(p)
The plot_ly
and add_trace
functions have an evaluation = FALSE
option that you can change to TRUE
, which should fix the scope issues.