0

このコードを三角形にプロットして、いくつかの領域でいくつかのポイントをトリプロットしようとしています:

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)

これは、ポイントを追加する必要があるプロットです

正則プロット

4

1 に答える 1

0

通常の 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")

ここに画像の説明を入力

于 2016-11-30T18:21:35.950 に答える