R 在三元图上画线

R 在三元图上画线,r,R,我有一个三元图,我生成如下: library(vcd) ternaryplot(abs(replicate(3, rnorm(50))), grid=FALSE) 我不喜欢内置网格,所以我禁用了它,但我想画一些自己的线:具体来说,我想画一条从三角形的每个点到对面中点的线(即三条线将三角形平分,并在中心交叉),我不太明白怎么做。我尝试了abline(),但当我这么做时,似乎什么也没发生 我如何在这个图上画线?试试这个。我通过阅读ternaryplot的代码收集了大部分信息: library(vc

我有一个三元图,我生成如下:

library(vcd)
ternaryplot(abs(replicate(3, rnorm(50))), grid=FALSE)
我不喜欢内置网格,所以我禁用了它,但我想画一些自己的线:具体来说,我想画一条从三角形的每个点到对面中点的线(即三条线将三角形平分,并在中心交叉),我不太明白怎么做。我尝试了
abline()
,但当我这么做时,似乎什么也没发生


我如何在这个图上画线?

试试这个。我通过阅读
ternaryplot
的代码收集了大部分信息:

library(vcd)
ternaryplot(abs(replicate(3, rnorm(50))), grid=FALSE)

top <- sqrt(3)/2
xlim <- c(-0.03, 1.03)
ylim <- c(-1, top)
pushViewport(viewport(width = unit(1, "snpc")))
pushViewport(viewport(width = 0.8, height = 0.8, xscale = xlim, 
                      yscale = ylim, name = "plot"))
grid.lines(c(0.75, 0.00), c(0.5 * top, 0))
grid.lines(c(0.25, 1.00), c(0.5 * top, 0))
grid.lines(c(0.50, 0.50), c(1.0 * top, 0))
upViewport(2)
库(vcd)
三元图(abs(复制(3,rnorm(50)),网格=FALSE)
top使用我最近在CRAN上发布的软件包,可以实现以下目标:

可使用以下代码生成:

library(ggtern)
DATA <- data.frame(x = c(1,0,0),
                   y = c(0,1,0),
                   z = c(0,0,1),
                   xend = c(0,.5,.5),
                   yend = c(.5,0,.5),
                   zend = c(.5,.5,0),
                   Series = c("yz","xz","xy"))
ggtern(data=DATA,aes(x,y,z,xend=xend,yend=yend,zend=zend)) + 
  geom_segment(aes(color=Series),size=1) +
  scale_color_manual(values=c("darkgreen","darkblue","darkred")) +
  theme_bw() + theme_nogrid() + 
  theme(legend.position=c(0,1),legend.justification=c(0,1)) + 
  labs(title = "Sample Midpoint Segments")
库(ggtern)

数据在最新版本ggtern 2.0.1中,现在有两种新的几何图形用于制作零件线,以下是一个示例:


我不确定这是否有帮助,但我昨天得到了一个答案,回答了我1.5年前的问题(),指出这看起来很有希望。@Beasterfield真有趣!我根据你问题的答案使用了ternaryplot:)这很好。有一个问题,您将如何调整(1)网格线,(2)边框,(3)开放符号的线厚度,例如pch=2(开放三角形)?
#Demonstrate the isoprop geometries
df   = data.frame(x=1,y=1,z=1)
ggtern(data=df,aes(x,y,z)) + geom_point() +
  geom_Tisoprop(value=seq(0,1,by=0.25),colour='darkred') +
  geom_Lisoprop(value=c(.5),colour='darkgreen') +
  geom_Risoprop(value=c(.5),colour='darkblue') +
  theme_minimal()