我想繪製的三維數據的投影使用GGPLOT2他們的單純。我以爲我可以管理使用coord_trans()
直角座標系的轉換,但不知道如何做到這一點沒錯。製作三元相圖
這是我的嘗試:
simplex.y <- function(x1, x2, x3) {
return(sqrt(0.75) * x3/(x1+x2+x3))
}
simplex.x <- function(x1, x2, x3) {
return((x2 + 0.5 * x3)/(x1+x2+x3))
}
x <- data.frame(
x1 = c(0, 0, 1, 0.1, 0.6, 0.2),
x2 = c(0, 1, 0, 0.3, 0.2, 0.8),
x3 = c(1, 0, 0, 0.6, 0.2, 0.0)
)
require(ggplot2)
ggplot(data = x, aes(x = c(x1, x2, x3), y = c(x1, x2, x3))) +
geom_point() +
coord_trans(x="simplex.x", y="simplex.y")
任何建議表示讚賞。非常感謝!
參見(http://askubuntu.com/questions/608519/how-to- [如何R中安裝ggtern包]安裝-ggtern封裝式-R) – Dante