用ggtern中的线连接观察结果

时间:2015-09-22 12:25:49

标签: r plot ggplot2 ggtern

无论如何,在每个连续点之间用直线连接ggtern中的观测值?我的代码是:

require(ggtern)    

x  <- data.frame(
      A = c( 0, 0, 1, 0.1, 0.6, 0.2,0.8,0.33 ),
      B = c( 0, 1, 0, 0.3, 0.2, 0.8, 0.1,0.33),
      C = c( 1, 0, 0, 0.6, 0.2, 0.0, 0.1,0.33)
    )


    ggtern(data=x,aes(A,B,C)) + 
        geom_point(fill="blue",type="l",shape=21,size=2) 
          theme_classic() )

1 个答案:

答案 0 :(得分:2)

geom_path(...)按顺序连接点。

ggtern(data=x,aes(A,B,C)) + 
  geom_path(color="green")+
  geom_point(type="l",shape=21,size=8) +
  geom_text(label=seq(nrow(x)), color="red")+
  theme_classic() 

我改变了点的大小和形状,并添加了标签,以表明它们是按顺序连接的。