1
votes

I have around 20.000 points in my scatter plot. I have a list of interesting points and want to show those points in the scatter plot with different color. Is there any simple way to do it? Thank you.

Further explanation,

I have a matrix, consist of 20.000 rows, let's say R1 to R20000 and 4 columns, let's say A,B,C, and, D. Each row has its own row.names. I want to make a scatter plot between A and C. It is easy with plot(data$A,data$B).

On the other hand, I have a list of row.names which I want to check where in the scatter plot those point is. Let's say R1,R3,R5,R10,R20,R25.

I just want to change the color of R1,R3,R5,R10,R20,R25 in the scatter plot different from other points. Sorry if my explanation is not clear.

1
Please consider showing a small reproducible exampleakrun

1 Answers

4
votes

If your data is in a simple form, then it is easy to do. For example:

# 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))

Imgur

Without a reproducible example, it's hard to say anything more specific.