rplotggplot2ggtern

connecting observations with lines in ggtern


Is there anyway of connecting observations in ggtern by a straight line between each consecutive point? My code is:

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() )

Solution

  • geom_path(...) connects the points in order.

    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() 
    

    I changed the size and shape of the points and added labels just to show that they are connected in order.