我希望得到与下例所示大致相同的结果。我在这两个函数之间犹豫是否要得到这个结果:geom_crosshair_tern
and scale_X_continuous
.
汉密尔顿,NE,和费里,M.(2018)。 ggtern:使用 ggplot2 的三元图。统计软件杂志,87(1), 1-17。 https://doi.org/10.18637/jss.v087.c03 https://i.stack.imgur.com/ksNpV.png
这是我到目前为止编写的脚本:
points1 <- data.frame(
rbind(c( 1,45,30,25),
c( 2,33,33,34),
c( 3,15,75,10)
)
)
colnames(points1) = c("IDPoint","X","Y","Z")
#geom_crosshair_tern version
base1 = ggtern(data=points1,aes(X,Y,Z)) +
theme_bw() +
tern_limits(labels=c(20,40,60,80,100), breaks=seq(0.2,1,by=0.2)) +
theme_clockwise() +
theme_showarrows() +
labs(title = "Test",Tarrow = "% X",Larrow = "% Y",Rarrow = "% Z") +
theme(tern.axis.arrow=element_line(size=1,color="black")) +
geom_point(shape=21,size=5,col="black",bg="slategray1") +
geom_text(aes(label=IDPoint),color="black") +
geom_crosshair_tern(lty=2)
这是我得到的geom_crosshair_tern
,但我有两个问题:
- 我不知道如何显示我的数据的真实价值;
- 我不知道如何将我的观点置于
geom_crosshair_tern
.
Is the scale_X_continuous
功能比较合适?我尝试了以下脚本,但没有成功。
points1 <- data.frame(
rbind(c( 1,45,30,25),
c( 2,33,33,34),
c( 3,15,75,10)
)
)
colnames(points1) = c("IDPoint","X","Y","Z")
labFnc <- function(x,digits=2) format(round(unique(x),digits),digits=digits)
base1 = ggtern(data=points1,aes(X,Y,Z)) +
scale_T_continuous(breaks=unique(points1$y),labels=labFnc(points1$y)+
scale_L_continuous(breaks=unique(points1$x),labels=labFnc(points1$x)+
scale_R_continuous(breaks=unique(points1$z),labels=labFnc(points1$z)+
theme_bw() +
tern_limits(labels=c(20,40,60,80,100), breaks=seq(0.2,1,by=0.2)) +
theme_clockwise() +
theme_showarrows() +
labs(title = "Test",Tarrow = "% X",Larrow = "% Y",Rarrow = "% Z") +
theme(tern.axis.arrow=element_line(size=1,color="black")) +
geom_point(shape=21,size=5,col="black",bg="slategray1") +
geom_text(aes(label=IDPoint),color="black")