R语言中arrows函数

2022-05-17 11:34:45  阅读：39  来源： 互联网

1、

```> plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
> arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4)```

2、 同时画两个箭头

```> plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
> arrows(x0 = c(1, 1),  y0 = c(1, 2),  x1 = c(4, 4), y1 = c(4, 5))```

3、 length参数条件箭须的长度。

```par(mfrow = c(1,3))
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "length = 0.1")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 0.1)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "length = 0.5")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 0.5)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "length = 1")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 1)```

4、code参数调整箭头的类型

```par(mfrow = c(1,3))
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "code = 1")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, code = 1)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "code = 2")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, code = 2)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "code = 3")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, code = 3)```

5、angle调整箭头的角度

```par(mfrow = c(1,3))
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "angle = 15")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 0.5, angle = 15)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "angle = 45")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 0.5, angle = 45)
plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n", main = "angle = 60")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, length = 0.5, angle = 60)```

6、其他常见参数

```plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4, col = "red", lwd = 10, lty = 1)```