在R中的ggtern包中,我试图给点贴上标签,但是我找不到一种更好的方式来定位标签,我在geom_text中玩过位置参数,但没有运气。
require(ggtern)
x <- data.frame(
A = c( 0.33, 0.4 ),
B = c( 0.33, 0.5),
C = c(0.33,0.1)
)
ggtern(data=x,aes(A,B,C)) +
geom_path(color="green")+
geom_point(type="l",shape=21,size=1) +
geom_text(label=c("(1/3,1/3,1/3)","(2/5,1/2,1/10)"), color="red")+
theme_classic()

我想知道以前有没有人处理过这个问题?
发布于 2015-09-25 07:34:36
您需要参数hjust和vjust
ggtern(data=x,aes(A,B,C)) +
geom_path(color="green")+
geom_point(type="l",shape=21,size=1) +
geom_text(label=c("(1/3,1/3,1/3)","(2/5,1/2,1/10)"), color="red", hjust=0, vjust=-1)+
theme_classic()参数position是根据帮助对此层上的重叠点使用的调整,而不是您所需要的。有关see和see的详细信息,请参阅this question。

https://stackoverflow.com/questions/32776337
复制相似问题