Guest User

Untitled

a guest
Feb 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. Timestamp_num=as.numeric(as.character(Timestamp))
  2. frames = max(Timestamp_num)
  3.  
  4. for(i in 1:frames){
  5. # creating a name for each plot file with leading zeros
  6. animationpath = file.path("C:","Users","Documents","Data
  7. Analysis","Plots",paste("animation_plot_",i,"_",format(Sys.time(), "%Y-%m-%d
  8. %Hh%Mm%Ss"), ".png", sep = ""))
  9.  
  10. #saves the plot as a .png file in the working directory
  11. png(file=animationpath, width=(framewidthx*2), height=(frameheighty*2),
  12. units="px", bg = "white",res=300)
  13. mytitle = paste("Desire Lines Animation_",i,"_",format(Sys.time(), "%Y-%m-%d
  14. %H:%M:%S"))
  15.  
  16. plot(boundx, boundy, type="n", xaxt = "n",yaxt = "n",main=mytitle, xlab="X
  17. location", ylab="Y
  18. location",xlim=c(0,framewidthx),ylim=c(0,frameheighty),asp=asprat)
  19.  
  20. #alpha specifies the transparency, 1=100% opaque
  21. #rainbow creates a rainbow of colors
  22. colors=rainbow(number_people, alpha=colorsalp)
  23.  
  24. axis(side = 1, at = xticks, labels = xticks)
  25. axis(side = 2, at = yticks, labels = yticks)
  26.  
  27. #creates a vector of random numbers equal to the number of people
  28. rcol = c(runif(number_people, 0.0, 1.0))
  29. gcol = c(runif(number_people, 0.0, 1.0))
  30. bcol = c(runif(number_people, 0.0, 1.0))
  31.  
  32. #create a new line for each person ID
  33. #pch specifies point type, cex changes pch size
  34. for (j in 1:length(unique(PersonID_Num))) {
  35. lines(boundx[PersonID_Num==unique(PersonID_Num)[j]],
  36. boundy[PersonID_Num==unique(PersonID_Num)[j]], type = "b",lwd = 1.5,
  37. lty = 1, col = rgb(rcol[j],gcol[j],bcol[j], alpha=colorsalp), pch=16,cex=1)
  38. }
  39. dev.off()
  40. }
Add Comment
Please, Sign In to add comment