焦静分享 http://blog.sciencenet.cn/u/jiaojiaojing 华师生态研二,以后从事理论生态学道路。

博文

Merry Christmas

已有 3638 次阅读 2010-12-24 22:24 |个人分类:未分类|系统分类:科研笔记| language, Greeting, animation

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))







https://blog.sciencenet.cn/blog-90740-397137.html

上一篇:生态统计人才需要的能力
下一篇:关于出国唠叨几句
收藏 IP: .*| 热度|

1 彭雷

发表评论 评论 (2 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-19 07:59

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部