R用不同的颜色区分一些点

R distinct some points with different color

我的散点图中有大约 20.000 个点。我有一个有趣的点列表,想在散点图中用不同的颜色显示这些点。有什么简单的方法吗?谢谢。

进一步说明,

我有一个矩阵,包含 20.000 行,比方说 R1 到 R20000 和 4 列,比方说 A、B、C 和 D。每一行都有自己的 row.names。我想在 A 和 C 之间绘制一个散点图。使用 plot(data$A,data$B) 很容易。

另一方面,我有一个 row.names 的列表,我想检查这些点在散点图中的位置。假设 R1、R3、R5、R10、R20、R25。

我只想改变散点图中R1、R3、R5、R10、R20、R25的颜色,使其与其他点不同。对不起,如果我的解释不清楚。

如果你的数据是一种简单的形式,那么就很容易做到。例如:

# Make some toy data
dat <- data.frame(x = rnorm(1000), y = rnorm(1000))

# List of indicies (or a logical vector) defining your interesting points
is.interesting <- sample(1000, 30) 

# Create vector/column of colours
dat$col <- "lightgrey"
dat$col[is.interesting] <- "red"

# Plot
with(dat, plot(x, y, col = col, pch = 16))

没有可重现的例子,很难说得更具体。