R:在极坐标中绘制半径 = 1 且角度为 0-2pi 的圆? [英] R: plot circle with radius = 1 and angle 0-2pi in polar -coordinates?

查看:69
本文介绍了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)

这篇关于R:在极坐标中绘制半径 = 1 且角度为 0-2pi 的圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆