娱乐 太极图

  • plotrix画太极图



library(plotrix)
#cycle.y is used to calculate the y-coordinates 
cycle.y <- function(center.x, center.y, radius, x){  
  if (max(x)>(center.x+radius)||min(x)<(center.x-radius)){ 
    stop("The range of x is too wide!!n")} else { 
      cycle.y.top <- sqrt(radius^2 - (x - center.x)^2) + center.y 
      cycle.y.bottom <- center.y - sqrt(radius^2 - (x - center.x)^2) 
      cycle.y <- matrix(c(cycle.y.top,cycle.y.bottom),2,length(x),byrow=TRUE)
      }
  } 
xllim <- 0 
xrlim <- xllim+8 
center.x <- (xllim + xrlim)/2 
center.y <- 4
radius <- 4 
x <- seq(xllim,xrlim,length=401)
xl <- x[x<=median(x)]
xr <- x[x>=median(x)] 
y <- cycle.y(center.x, center.y, radius, x) 
yl <- y[,1:round((ncol(y)+1)/2)] 
yr <- y[,round((ncol(y)+1)/2):ncol(y)] 
par(bg=colors()[657]) 
plot(c(center.x-radius,center.x+radius), c(center.y-radius,center.y+radius),
     type="n", bty="n", xlab="", ylab="", xaxt="n", yaxt="n")
title(main = "太极图", cex.main =2) 
polygon(c(xl,rev(xl)), c(yl[1,],rev(yl[2,])), col="white", border = "transparent") 
polygon(c(xr,rev(xr)), c(yr[1,],rev(yr[2,])), col="black", border = "transparent")  
center.yt <- center.y+center.y/2
center.yb <- center.y-center.y/2
radius1 <- radius/2 
xl1 <- xl[xl>=median(xl)]
xr1 <- xr[xr<=median(xr)] 
yl1 <- cycle.y(center.x, center.yb, radius1, xl1)
yr1 <- cycle.y(center.x, center.yt, radius1, xr1) 


polygon(c(xl1,rev(xl1)), c(yl1[1,],rev(yl1[2,])), col="black", border = "transparent") 
polygon(c(xr1,rev(xr1)), c(yr1[1,],rev(yr1[2,])), col="white", border = "transparent")
radius2 <- radius1/8
library(plotrix)  
draw.circle(center.x, center.yt, radius2, col="black") 
draw.circle(center.x, center.yb, radius2, col="white") 

img_731cd6ec1bcbc5e84ff4f64ed4ecb7cc.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值