Hi
I have and algorithm which found some new 2D lines in each iteration, I want to add this lines to ggplot frequently, I searched for it but I can't find a good example,
I write it using normal plot and that's it:
plot(c(0 , Len1), c(0, Len2), type= "n",xlim=c(0,Len1), ylim=c(0,Len2))
for(j in 1:maxa){
for (k in 1:8) {
if( someCondition ){
lines(x = c(br[j,1],br[j+k,1]) , y=c(br[j,3],br[j+k,3]),col="blue")
}
}
}
and this is my current result:
Now I want to write a same thing but with ggplot2
Thanks all
We can use the same logic to add lines in a loop, something like:
mygg <- ggplot(data... aes(....)) + geom_line()
, then do the same inside for loop but adding on top of existing plot,mygg <- mygg + geom_line(data ... aes(....))
Curse you, I was typing my answer. :)
Do you mean to animate it? If so see gganimate and tweenr packages.