假设 (x(t),y(t)) 具有极坐标 (√t,2πt)。为 t∈[0,10] 绘制 (x(t),y(t))。
R 中没有适当的函数来绘制极坐标。我通过给出 x=√t & y=2πt 来尝试正常绘图。但是结果图并不像预期的那样。
我从“Introduction to Scientific Programming and Simulation using r”中得到了这个问题,这本书告诉我情节应该是螺旋式的。
假设 (x(t),y(t)) 具有极坐标 (√t,2πt)。为 t∈[0,10] 绘制 (x(t),y(t))。
R 中没有适当的函数来绘制极坐标。我通过给出 x=√t & y=2πt 来尝试正常绘图。但是结果图并不像预期的那样。
我从“Introduction to Scientific Programming and Simulation using r”中得到了这个问题,这本书告诉我情节应该是螺旋式的。
做一个序列:
t <- seq(0,10, len=100) # the parametric index
# Then convert ( sqrt(t), 2*pi*t ) to rectilinear coordinates
x = sqrt(t)* cos(2*pi*t)
y = sqrt(t)* sin(2*pi*t)
png("plot1.png");plot(x,y);dev.off()
这不显示连续字符,因此添加线以连接序列中的相邻点:
png("plot2.png");plot(x,y, type="b");dev.off()
正如之前的评论中已经提到的,R 可以使用极坐标进行绘图。包 plotrix 有一个名为 polar.plot 的函数来执行此操作。极坐标由长度和角度定义。此函数可以采用一系列长度和一系列角度来绘制极坐标。例如制作一个螺旋:
library(plotrix)
plt.lns <- seq(1, 100, length=500)
angles <- seq(0, 5*360, length=500)%%360
polar.plot(plt.lns, polar.pos=angles, labels="", rp.type = "polygon")
值得一试的选项,它是Plotly包。
library(plotly)
p <- plot_ly(plotly::mic, r = ~r, t = ~t, color = ~nms, alpha = 0.5, type = "scatter")
layout(p, title = "Mic Patterns", orientation = -90)
注意:如果您使用的是 RStudio,则绘图将显示在查看器选项卡中。