|||
Nowadays, I am very interested in "animation" package in R language. So today I made a simple animated picture by R to express my best wishes to every one.
the results:
R script:
library(MASS)
library(animation)
pp<-function(N)
{
x1<-runif(N,0,N)
y1<-runif(N,0,N)
par(ann=F,bg = "darkblue")
x<-seq(1,30*N)
j<-sample(x,30)
plot(1, ann = F, type = "n", axes = F,xlim=c(0,N),ylim=c(0,N))
points(j,N-1.5*rep(1,30),pch=19,col="white",cex=2)
for(i in 2:N)
{
x<-seq(1,30*N)
x<-x[-j]
j<-c(sample(x,30),j)
plot(1, ann = F, type = "n", axes = F,xlim=c(0,N),ylim=c(0,N))
y<-N-1.5*rep(1:i,rep(30,i))
points(j,y,pch=19,col="white",cex=2)
z<-sample(N,length(x1),replace=T)
#plot(1, ann = F, type = "n", axes = F,xlim=c(0,N),ylim=c(0,N))
points(x1[i],y1[i],pch=19,col=N-i,cex=3)
points(x1[i+1],y1[i+1],pch=19,col=N-i-1,cex=2.5)
text(N/2, N/2, "Merry Christmas", srt = 12*i, col =
rainbow(N)[i], cex = 4.5 * i/N)
Sys.sleep(0.005)
}
}
saveMovie(pp(30))
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-4-19 07:59
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社