日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

用R語言畫蝴蝶曲線

 新用戶5228KeDY 2021-10-10

用R語言畫蝴蝶曲線

蝴蝶曲線的極坐標(biāo)方程為

參數(shù)取值范圍為。

寫成參數(shù)方程,為

參數(shù)取值范圍與極坐標(biāo)下是相同的。一般為了追求曲線多一些變化,往往把改寫成

這些天不少文章用matlab、mathematica、maple、python語言,甚至scratch、VBA等繪制它,卻唯獨少了R語言。然而R語言在可視化的表現(xiàn)力方面是相當(dāng)相當(dāng)強大的。下面用R來畫蝴蝶曲線。

在參數(shù)方程下用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()

在參數(shù)方程下直接使用plot低水平函數(shù)繪制

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")

極坐標(biāo)方程下用IDPmisc極坐標(biāo)轉(zhuǎn)直角坐標(biāo)

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極坐標(biāo)轉(zhuǎn)直角坐標(biāo)的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')

把直角坐標(biāo)彎曲對應(yīng)到平面圓里面

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極坐標(biāo)轉(zhuǎn)直角坐標(biāo)的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()  

    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多