TA的每日心情 | 奋斗 2015-7-30 23:05 |
---|
签到天数: 12 天 [LV.3]偶尔看看II
管理员
- 积分
- 4804
|
- plottest111=function(r,rpoints,mat)
- {
- a.col=ncol(mat)
- if(a.col%%2==0)
- {
- n=2*(1:a.col)-1
- xplace=r*cos(pi/2+2*pi/a.col/2*n)
- yplace=r*sin(pi/2+2*pi/a.col/2*n)
- }else
- {
- xplace=r*cos(pi/2+(2*pi/a.col*((1:a.col)-1)))
- yplace=r*sin(pi/2+(2*pi/a.col*((1:a.col)-1)))
- }
- plot(0,0,col="white",xlim=c(-1.25*r,1.25*r),ylim=c(-1.25*r,1.25*r),frame.plot=F,axes=F,xlab="",ylab="")
- for(i in 1:a.col)
- {
- for(j in 1:i)
- if(mat[i,j]!=0)
- {
- a=xplace[c(i,j)];b=yplace[c(i,j)]
- lines(x=a,y=b,col="gray",lwd=1.25*mat[i,j])
- }
- }
- par(new=T)
- plot(x=xplace,y=yplace,col=rainbow(100)[50],pch=16,cex=rpoints,xlim=c(-1.25*r,1.25*r),ylim=c(-1.25*r,1.25*r),frame.plot=F,axes=F,xlab="",ylab="")
- points(xplace,yplace,cex=rpoints,pch=1,col="red")
- text(x=xplace,y=yplace,names(mat))
- }
- ###参数部分:r 画面的半径
- r=3;rpoints=4
- par(mfrow=c(2,4))
- ###点的坐标以及画图
- for(i in 3:10)
- {
- b=matrix(sample(0:5,replace=T,size=i^2,prob=c(0.6,0.1,0.08,0.08,0.08,0.06)),ncol=i)
- b=as.data.frame(b)
- names(b)=letters[1:i]
- rownames(b)=letters[1:i]
- b[lower.tri(b)]=b[upper.tri(b)]
- b[!(upper.tri(b)|lower.tri(b))]=0
- plottest111(b,r=r,rpoints=rpoints)
- }
复制代码
|
|