inst/examples/lines-demo.R

# 曲线、直线、直线段、箭头的展示说明
# 不作图,只画出框架,且指定坐标轴范围
plot(1:10, type = "n", xlim = c(0, 10), ylim = c(0, 10),
     xlab = "", ylab = "")
lines(1:10, abs(rnorm(10))) # 10 个正态随机数绝对值的波动线
abline(a = 0, b = 1, col = "gray") # 不同的直线
abline(v = 2, h = 2, lty = 2)
text(8, 3, "abline(a = 0, b = 1)") # 添加文本
arrows(8, 3.5, 6, 5.7, angle = 40) # 添加箭头
# 参数用了向量:不同灰度的线段
segments(rep(3, 4), 6:9, rep(5, 4), 6:9,
         col = gray(seq(0.2, 0.8, length = 4)))
text(4, 9.8, "直线段")
yihui/MSG documentation built on Aug. 16, 2021, 12:13 p.m.