用R画蛇

蛇年吉祥物,她是多么的漂亮…

图形

蛇图

代码

y <- seq(2*pi,0,length=150) 
x <- sin(y) 
plot(x, y, type = "n", xlim = c(-8, 5), ylim = c(-2,8), xlab = "", ylab = "", main = "", asp = 1) 
twist_seq<-c(seq(1,0.8, length = 75),seq(0.8,1, length = 75)) 
y_radius=y*twist_seq 
radius = ifelse(0.5 * abs(cos(y_radius)) + 0.1 < 0.15, 0.15, 
0.5 * abs(cos(y_radius)) + 0.1) 
fat_seq<-c(seq(pi, 2*pi, length = 30),seq(2 * pi, pi, length = 120))/(2*pi) 
radius<-radius*fat_seq 
x = sin(y_radius) 
pose_seq=seq(1,2,length=150) 
x_snake=x*pose_seq 
symbols(x_snake, y, circles = radius, inches = FALSE,fg=heat.colors(300)[1:150], 
add = TRUE) 
symbols(x_snake[1]-0.1, y[1]+0.1, circles = 0.1, inches = FALSE, bg="red",fg="red", 
add = TRUE) 
symbols(x_snake[1]+0.1, y[1]-0.1, circles = 0.1, inches = FALSE, bg="red",fg="red", 
add = TRUE) 
arrows( x_snake[1]+0.2, y[1]+0.2, x_snake[1]+radius[1]*2, y[1]+radius[1]*2, 
col = "red", lwd = 2, angle = 150) 
x = sin(y) 
twist_seq<-c(seq(1,0.8, length = 75),seq(0.8,1, length = 75)) 
y_radius=y*twist_seq 
radius = ifelse(0.5 * abs(cos(y_radius)) + 0.1 < 0.15, 0.15, 
0.5 * abs(cos(y_radius)) + 0.1) 
radius<-radius*seq(pi,0, length = 150)/(2*pi) 
symbols(y-2*pi, x/2, circles = radius, inches = FALSE, fg=heat.colors(300)[151:300], 
add = TRUE)
石见 石页 /
在共享协议(CC)下发布于
类别: technology 
标签: r  中