r = 2.5

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

for ( i in 1:10){

if( i %% 2 == 1) { k = (i+1)/2 x[i] <- r * cos((0.5 + k * 2/5) * pi) y[i] <- r * 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.25) + 5 y <- (y * 6.25) + 5

plot(x, y, xlab = '', ylab = '', xlim = c(2.5, 15), ylim = c(2.5, 15), axes = T, type = "o") polygon(x, y, col = "transparent", border = "black", lwd = 1.5)

修改标签顺序

text(x[c(3, 2, 1, 10, 9, 8, 7, 6, 5, 4)], y[c(3, 2, 1, 10, 9, 8, 7, 6, 5, 4)], labels= c('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'), pos = 1)

R语言图形绘制:设置坐标范围并实现顶点标签顺时针标记

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

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