作者gsuper (Logit(odds))
看板R_Language
標題[分享] xy xcatter plot, 座標旋轉
時間Mon Jun 1 16:42:48 2015
#############################################
#############################################
### 圖片角度調整
[旋轉角度]
a <- cbind(c(1,0,-1,0,0.5),c(0,1,0,-1,0.5))
b <- a
degree <- 60
b[,1] <- a[,1]*cos(2*pi/360*degree) - a[,2]*sin(2*pi/360*degree)
b[,2] <- a[,1]*sin(2*pi/360*degree) + a[,2]*cos(2*pi/360*degree)
COLOR <- c("red","orange","blue","purple","black")
par(mfrow=c(1,2))
plot(a,xlim=c(-2,2),ylim=c(-2,2),lty=1,col=COLOR,pch=19)
plot(b,xlim=c(-2,2),ylim=c(-2,2),lty=1,col=COLOR,pch=19)
#############################################
[鏡像]
b <- a ; b[,1] <- -a[,1] # 左右
b <- a ; b[,2] <- -a[,2] # 上下
#############################################
[重心計算]
group <- c(1,1,2,2,2)
Cen1 <- colMeans(a[group==1,])
Cen2 <- colMeans(a[group==2,])
#############################################
[夾角計算]
#############################################
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.250.41
※ 文章網址: https://webptt.com/m.aspx?n=bbs/R_Language/M.1433148171.A.373.html
1F:推 celestialgod: 推薦你可以用rgl畫,可以自由旋轉.... 06/01 17:10
※ 編輯: gsuper (140.113.250.41), 06/01/2015 17:44:29
2F:→ celestialgod: 我誤會你的圖了... 06/01 17:49
※ 編輯: gsuper (140.113.250.41), 06/01/2015 17:55:46
3F:→ celestialgod: 你可以改成用Givens rotation 06/01 17:53
4F:→ celestialgod: rot_mat = function(degree) cos(degree*2*pi/360)+ 06/01 17:53
5F:→ celestialgod: c(0,sin(degree*2*pi/36)*c(-1,1),0) 06/01 17:54
6F:→ celestialgod: b = a %*% rot_mat(degree) 06/01 17:54
7F:→ gsuper: 行列式有點苦手 06/01 17:57
※ 編輯: gsuper (114.32.201.238), 06/08/2015 09:44:07
※ 編輯: gsuper (114.32.201.238), 06/08/2015 10:52:06
8F:→ celestialgod: 不太懂你的電子雲要做什麼?很多變數都沒有 06/08 11:00
9F:→ celestialgod: 跑不出來Q____Q 06/08 11:00
姑且是像筆記一樣的東西
可能最後變成 2D scatter plot 的操作 之類的文章吧
慢慢更新不著急
※ 編輯: gsuper (114.32.201.238), 06/08/2015 11:42:17
※ 編輯: gsuper (114.32.201.238), 07/02/2015 09:39:25
※ 編輯: gsuper (114.32.201.238), 07/02/2015 09:44:03