【问题标题】:How do I label the points of my scatterplot in R?如何在 R 中标记散点图的点?
【发布时间】:2021-08-16 18:23:54
【问题描述】:

我有一个包含约 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 而不是行号?

【问题讨论】:

  • 我认为你需要labels = TPMProtCod_J1.1_J1.2$ENSEMBL。不是行名。
  • 是的,谢谢!

标签: r labeling


【解决方案1】:

看来你需要把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)

【讨论】:

    猜你喜欢
    • 2013-10-31
    • 2012-03-18
    • 2012-10-25
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-05
    相关资源
    最近更新 更多