R:在极坐标中,半径= 1,角度为0-2pi的情节圆?

hhh*_*hhh 1 plot r

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

$$ r\COS \左(\压裂{2\PI} {3} \左(\压裂{3\THETA} {2\PI} - \左\ lfloor \压裂{3\THETA} {2\PI}\right\rfloor\right) - \frac {\ pi} {3}\right)= 1 $$

也许相关

  1. 试图绘制上面的函数,更多这里,LaTex这个hack 在这里可见.

  2. 用ggplot2画一个圆圈

  3. 极坐标中的正多边形

Eti*_*rie 5

您可以轻松地在ggplot2中获取极坐标图.

来自ggplot2网站:

library(ggplot2)    

cxc <- ggplot(mtcars, aes(x = factor(cyl))) + 
           geom_bar(width = 1, colour = "black") 

cxc <- cxc + coord_polar()

print(cxc)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


tim*_*ffe 5

您还可以使用几何体创建圆

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)
Run Code Online (Sandbox Code Playgroud)

  • 你最好不要忘记宽高比,'asp = 1`,在调用plot命令时看到它真的是一个圆圈. (4认同)