繁体   English   中英

我如何 label 我的散点图在 R 中的点?

[英]How do I label the points of my scatterplot in R?

我有一个包含约 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)

在此处输入图像描述

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

看来您需要将row.names(...)更改为TPMProtCod_J1.1_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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM