如何在R中标记散点图的点?

如何在R中标记散点图的点?,r,labeling,R,Labeling,我有一个包含10000行和3列的数据框: ENSEMBL J1.1 J1.2 ENSG00000166710 800 900 ENSG00000163220 15000 32500 ENSG00000156508 600 900 ... > as.data.frame(colnames(TPMProtCod_J1.1_J1.2)) colnames(TPMProtCod_J1.1_J1.2) 1

我有一个包含10000行和3列的数据框:

ENSEMBL            J1.1     J1.2
ENSG00000166710    800      900
ENSG00000163220    15000    32500
ENSG00000156508    600      900
...

> as.data.frame(colnames(TPMProtCod_J1.1_J1.2))
  colnames(TPMProtCod_J1.1_J1.2)
1                        ENSEMBL
2                           J1.1
3                           J1.2
> dim(TPMProtCod_J1.1_J1.2)
[1] 10602     3
我用以下代码创建了一个散点图:

plot(TPMProtCod_J1.1_J1.2$J1.1, TPMProtCod_J1.1_J1.2$J1.2, col = "lightblue", pch=19, cex=2, xlab = "J1.1 (TPM)", ylab = "J1.2 (TPM)")
text(TPMProtCod_J1.1_J1.2$J1.1, TPMProtCod_J1.1_J1.2$J1.2, labels = row.names(TPMProtCod_J1.1_J1.2), cex= 0.9)


但是如何使每个点显示相应的ensembl ID而不是行号?

似乎需要将
行名称(…)
更改为
TPMProtCod\u J1.1\u J1.2$ensembl

text(TPMProtCod_J1.1_J1.2$J1.1,TPMProtCod_J1.1_J1.2$J1.2,labels=TPMProtCod_J1.1_J1.2$ENSEMBL,cex=0.9)

我想您需要
标签=TPMProtCod\u J1.1\u J1.2$ENSEMBL
。不是rownames。是的,这很有效,谢谢!