您可以使用以下函数轻松完成此arrows 操作:
x <- c(0,2)
y <- c(1,2)
plot(x,y)
arrows(x[1],y[1],x[2],y[2])
Run Code Online (Sandbox Code Playgroud)
对于 3D 向量,请检查plot3D 包。arrows3D它具有能够绘制单个 3D 矢量的功能。有关此包的更多信息,请查看文档
arrows3D (0, 0, 0, 3, 3, 3,
colvar = NULL, phi = 40, theta = 40,
col = NULL, NAcol = "white", breaks = NULL,
colkey = NULL, panel.first = NULL,
clim = NULL, clab = NULL, bty = "b", type = "triangle",
add = FALSE, plot = TRUE)
Run Code Online (Sandbox Code Playgroud)