Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Timestamp_num=as.numeric(as.character(Timestamp))
- frames = max(Timestamp_num)
- for(i in 1:frames){
- # creating a name for each plot file with leading zeros
- animationpath = file.path("C:","Users","Documents","Data
- Analysis","Plots",paste("animation_plot_",i,"_",format(Sys.time(), "%Y-%m-%d
- %Hh%Mm%Ss"), ".png", sep = ""))
- #saves the plot as a .png file in the working directory
- png(file=animationpath, width=(framewidthx*2), height=(frameheighty*2),
- units="px", bg = "white",res=300)
- mytitle = paste("Desire Lines Animation_",i,"_",format(Sys.time(), "%Y-%m-%d
- %H:%M:%S"))
- plot(boundx, boundy, type="n", xaxt = "n",yaxt = "n",main=mytitle, xlab="X
- location", ylab="Y
- location",xlim=c(0,framewidthx),ylim=c(0,frameheighty),asp=asprat)
- #alpha specifies the transparency, 1=100% opaque
- #rainbow creates a rainbow of colors
- colors=rainbow(number_people, alpha=colorsalp)
- axis(side = 1, at = xticks, labels = xticks)
- axis(side = 2, at = yticks, labels = yticks)
- #creates a vector of random numbers equal to the number of people
- rcol = c(runif(number_people, 0.0, 1.0))
- gcol = c(runif(number_people, 0.0, 1.0))
- bcol = c(runif(number_people, 0.0, 1.0))
- #create a new line for each person ID
- #pch specifies point type, cex changes pch size
- for (j in 1:length(unique(PersonID_Num))) {
- lines(boundx[PersonID_Num==unique(PersonID_Num)[j]],
- boundy[PersonID_Num==unique(PersonID_Num)[j]], type = "b",lwd = 1.5,
- lty = 1, col = rgb(rcol[j],gcol[j],bcol[j], alpha=colorsalp), pch=16,cex=1)
- }
- dev.off()
- }
Add Comment
Please, Sign In to add comment