2

最近、1 つの画像内に複数のグラフを表示する方法について質問しました。かなり良い回答が得られましたが、まだ 1 つの質問が残っています。

散布図のドットをラベルに変更するには? プロットは次のようになりますここに画像の説明を入力

ここで、すべての黒い点をデータの行名に変更したいと考えています。プロットに使用するコードは次のとおりです。

plotAll<-function(data){
  combs <- expand.grid(names(data), names(data))
  out <- do.call(rbind, apply(combs, 1, function(x) {
    tt <- data[, x]; names(tt) <- c("V1", "V2")
    tt <- cbind(tt, id1 = x[1], id2 = x[2])
  }))

  library(plyr)
  df.text=ddply(out[out$id1==out$id2,],.(id1,id2),summarise,
                pos=max(V1)-(max(V1)-min(V1))/2)
  out[out$id1==out$id2,c("V1","V2")]<-NA
  ggplot(data = out, aes(x = V2, y = V1)) + geom_point(alpha = 0.5) +
    facet_grid(id1 ~ id2,scales="fixed")+
    geom_text(data=df.text,aes(pos,pos,label=id1)) + geom_abline( slope=1 ) + 
    ggtitle("Corralation between measured & calculated affinities") +
    ylab("") + xlab("") + theme(panel.grid.minor.x=element_blank(), panel.grid.major.x=element_blank())
}

geom_point(alpha=0.5)の設定を何かに変更する必要があることはわかっていますが、それによってgeom_text(label=rownames(data))軸が削除され、行名が y 軸とデータポイントに配置されます。したがって、おそらく私はプロットのレイアウトで何か間違ったことをしましたが、それが何であるかは疑問のままです.

4

1 に答える 1