使用 ggtern 的三角图

triangular plot using ggtern

我正在尝试用三角图中的某些区域对某些点进行三重绘制此代码:

library(ggtern)
g <- data.frame(x=c(1,.6,.6), y=c(0,.4,0), z=c(0,0,.4), Series="Green")
r <- data.frame(x=c(0,0.4,0), y=c(0,0,0.4), z=c(1,0.6,0.6),     Series="Red")
p <- data.frame(x=c(0,0.4,0), y=c(1,0.6,0.6), z=c(0,0,0.4),  Series="Purple")
DATA = rbind(g,r,p)

plot <- ggtern(data=DATA,aes(x,y,z)) +
  geom_polygon(aes(fill=Series),alpha=.5,color="black",size=0.25) +
  scale_fill_manual(values=as.character(unique(DATA$Series))) +
  theme(legend.position=c(0,1),legend.justification=c(0,1)) +
  labs(fill="Region",title="Sample Filled Regions")

print(plot)

我想在该图中添加一些取自文本文件的点,我正在读取它们的 x、y 和 z 坐标。我如何才能将这些点指向情节?

如果我尝试这样的操作,它会删除之前的情节:

plot <- ggtern(data = data.frame(x = cordnate_x, y = cordnate_y, z = cordnate_z),aes(x, y, z)) + geom_point() +theme_rgbg()
print(plot)

这是需要加分的情节

traingular plot

您可以像拥有普通的 ggplot 对象一样添加点。

g <- data.frame(x=c(1,.6,.6), y=c(0,.4,0), z=c(0,0,.4), Series="Green")
r <- data.frame(x=c(0,0.4,0), y=c(0,0,0.4), z=c(1,0.6,0.6), Series="Red")
p <- data.frame(x=c(0,0.4,0), y=c(1,0.6,0.6), z=c(0,0,0.4), Series="Purple")
DATA = rbind(g,r,p)    

temp <- data.frame(x=c(0.4), y=c(0.6), z=c(0.4))
plot<- ggtern(data=DATA,aes(x,y,z)) +
    geom_polygon(aes(fill=Series),alpha=.5,color="black",size=0.25) +
    scale_fill_manual(values=as.character(unique(DATA$Series))) +
    theme(legend.position=c(0,1),legend.justification=c(0,1)) +
    labs(fill="Region",title="Sample Filled Regions") +
    geom_point(data = temp, colour = "red") +
    annotate("text", x = 0.3, y = 0.6, z = 0.4, label = "Some text")