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

时间:2012-03-23 10:39:22

标签: r plot

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

示例

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

也许是相关的

  1. 尝试绘制上述函数,更多here,LaTex可以看到这个hack here

  2. Draw a circle with ggplot2

  3. Regular polygons in polar coordinates

3 个答案:

答案 0 :(得分:5)

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

From the ggplot2 website:

library(ggplot2)    

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

cxc <- cxc + coord_polar()

print(cxc)

enter image description here

答案 1 :(得分: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)

答案 2 :(得分:2)

您可以使用包circular执行非常好的循环统计。以下是该软件包中的一个示例:

require(circular)
x <- circular(runif(50, 0, 2*pi))
rose.diag(x, bins = 18, main = 'Uniform Data',col=2)
points(x)

enter image description here