我想得到与下面示例中显示的大致相同的结果。我在这两个函数之间犹豫以获得这个结果:geom_crosshair_tern
和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")
#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
。
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")