r - 将观察结果与 ggtern 中的线连接起来

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

最佳答案

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

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

关于r - 将观察结果与 ggtern 中的线连接起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32716823/

相关文章:

r - 如何计算落在树的每个节点中的观察值

r - 在同一窗口中绘制一个或多个图

r - ggplot x 轴作为带小时的日期

r - 在 R 中将特定字符串与 HGVS 格式分开

python - 二维核密度图的主要差异 : Seaborn and R

r - 为什么这不在一张图中绘制多个函数?

r - ggplot2 中密度图叠加中的警告消息

r - 没有数据时如何避免geom_line或geom_path中的连接线?

r - 带编号的点标签加上散点图中的图例

R:在单个因子变量上加宽多个列