r = 2.568

x <- matrix() y <- matrix()

for ( i in 1:10){

if( i %% 2 == 1) { k = (i+1)/2 x[i] <- cos((0.5 + k * 2/5) * pi) y[i] <- -sin((0.5 + k * 2/5) * pi) }

else if(i %% 2 == 0) { k = i/2 x[i] <- (r * cos((0.7 + k * 2/5 ) *pi)) y[i] <- -(r * sin((0.7 + k * 2/5 ) *pi)) } }

x <- (x * 6) + 9 # 将x的范围由[-1,1]变为[2.2,15]

y <- (y * 6) + 9 # 将y的范围由[-1,1]变为[2.2,15]

par(bg = "blue")

plot(x, y, xlab = '', ylab = '', # xlim = c(0, 15), # ylim = c(0, 15), axes = T, type = "o") polygon(x, y, col = "transparent", border = "black", lwd = 1.5) #为五角星填充颜色

text(x, y, labels= c('C', 'B', 'A', 'J', 'I', 'H', 'G', 'F', 'E', 'D'), pos = 1)

R语言图形翻转:将图形上下翻转的代码示例

原文地址: https://www.cveoy.top/t/topic/lQfR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录