用R语言画蝴蝶曲线蝴蝶曲线的极坐标方程为 参数取值范围为。 写成参数方程,为
参数取值范围与极坐标下是相同的。一般为了追求曲线多一些变化,往往把改写成。 这些天不少文章用matlab、mathematica、maple、python语言,甚至scratch、VBA等绘制它,却唯独少了R语言。然而R语言在可视化的表现力方面是相当相当强大的。下面用R来画蝴蝶曲线。 在参数方程下用ggplot2包绘制t<-seq(from = 0, to = 12*pi, by = 0.005) x<-sin(t)*(exp(cos(t)) - 2*cos(4*t)-(sin(t/11))^5) y<-cos(t)*(exp(cos(t)) - 2*cos(4*t)-(sin(t/11))^5) mydata<-data.frame(x = x, y = y) library(ggplot2) ggplot(data = mydata,aes(x = x, y = y))+ geom_point(colour = 'blue')+ coord_cartesian()

在参数方程下直接使用plot低水平函数绘制
t<-seq(from = 0, to = 12*pi, by = 0.005) x<-sin(t)*(exp(cos(t)) - 2*cos(4*t)-(sin(t/11))^5) y<-cos(t)*(exp(cos(t)) - 2*cos(4*t)-(sin(t/11))^5) mydata<-data.frame(x = x, y = y) par(mfrow=c(2,1)) plot(x,y,"s",col="blue") plot(x,y,"h",col="cyan2")

极坐标方程下用IDPmisc极坐标转直角坐标
t<-seq(from = 0, to = 12*pi, by = 0.005) r <-exp(cos(t))-2*cos(4*t)+(sin(t/12))^5 library(IDPmisc) #小心IDPmisc极坐标转直角坐标的phi用度作为角单位 xy <- clock2cart(rho=r,phi=t/pi*180,circle=-360)
library(ggplot2) ggplot(data = xy,aes(x = x, y = y))+ geom_point(colour = 'red')

把直角坐标弯曲对应到平面圆里面
t<-seq(from = 0, to = 12*pi, by = 0.005) r <-exp(cos(t))-2*cos(4*t)+(sin(t/12))^5 library(IDPmisc) #小心IDPmisc极坐标转直角坐标的phi用度作为角单位 xy <- clock2cart(rho=r,phi=t/pi*180,circle=-360)
library(ggplot2) ggplot(data = xy,aes(x = x, y = y))+ geom_point(colour = 'red')+ coord_polar()

|