如何在绘图上画半圆?

TFC*_*TFC 1 plot trigonometry r draw

我正在尝试使用 R 中的三角函数在绘图上绘制一些半圆。所以这就是我所拥有的:

matPoints <<- as.data.frame(cbind(X=c(-1, -(sqrt(3)/2), -(sqrt(2)/2), -0.5, 0, 0.5, sqrt(2)/2, sqrt(3)/2, 1), Y=c(0, 0.5, sqrt(2)/2, sqrt(3)/2, 1, sqrt(3)/2, sqrt(2)/2, 0.5, 0)))

plot(x = matPoints$X*W, y = matPoints$Y*W)
Run Code Online (Sandbox Code Playgroud)

目前,它打印绘图上的每个点。我想要在这里做的是在点之间绘制一条平滑的线,这样它就会给我一个中心为 (0, 0) 且比例为 W 的漂亮半圆。

有什么解决办法吗?

Par*_*ark 5

你是这个意思吗?

x <- seq(0, pi, length.out = 500)
W <- 3
plot(cos(x) * W, sin(x) * W, type = "l")
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述