R:在极坐标中绘制半径 = 1 且角度为 0-2pi 的圆?

问题描述:

我在 R 中找到了 plotrix 包,但还没有找到如何在 R 中做这个简单的圆.基本上,我怎样才能做一个半径为 1 和 0:360 度角的极坐标图,生成一个圆?

I found the plotrix package in R but cannot yet find how to do this simple circle in R. Basically, how can I do a polar-plot with radius of 1 and 0:360 angles in degree, generating a circle?

示例

$$r\cos\left(\frac{2\pi}{3}\left(\frac{3\theta}{2\pi}-\left\lfloor\frac{3\theta}{2\pi}\right\rfloor\right) -\frac{\pi}{3}\right) = 1$$

$$r\cos\left(\frac{2\pi}{3}\left(\frac{3\theta}{2\pi}-\left\lfloor\frac{3\theta}{2\pi}\right\rfloor\right) -\frac{\pi}{3}\right) = 1$$

也许相关

  1. 尝试绘制上述函数,更多这里,LaTex with this hack 此处可见.

  1. Trying to plot the above function, more here, the LaTex with this hack here visible.

用ggplot2画一个圆

极坐标中的正多边形

你也可以用几何制作圆

circle <- function(x, y, rad = 1, nvert = 500, ...){
    rads <- seq(0,2*pi,length.out = nvert)
    xcoords <- cos(rads) * rad + x
    ycoords <- sin(rads) * rad + y
    polygon(xcoords, ycoords, ...)
}

# asp = 1 due to Hans' comment below- wouldn't let me leave a comment just saying 'thanks'
plot(-5:5, type="n", xlim = c(-5,5), ylim = c(-5,5), asp = 1)
circle(0,0,4)
circle(-1.5,1.5,.5)
circle(1.5,1.5,.5)
circle(0,0,1)
segments(-2,-2,2,-2)