R语言图形坐标范围调整:将XY轴范围设定在2.5到15之间
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.25) + 2.5 # 将x的范围由[-1,1]变为[2.5,15] y <- (y * 6.25) + 2.5 # 将y的范围由[-1,1]变为[2.5,15] par(bg = 'blue') 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, y, labels= c('C', 'B', 'A', 'J', 'I', 'H', 'G', 'F', 'E', 'D'), pos = 1)
原文地址: https://www.cveoy.top/t/topic/lQfW 著作权归作者所有。请勿转载和采集!