Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place circles around specific data points on a scatter plot in R?

Tags:

r

My question is two fold:

1) Is it possible to place a circle around specific data points on a scatter plot in R?
2) If so, how would I place separate circles of a defined radius around (5, 6) and (18, 23) given the following data.

x <- c(2, 5, 7, 9, 12, 16, 18, 21)
y <- c(3, 6, 10, 13, 15, 19, 23, 25)
plot(x, y)

(NB: This is not a request to colour specific data points on the plot, but to place a circle around them)

like image 851
Alison Bennett Avatar asked Dec 15 '22 14:12

Alison Bennett


1 Answers

Check out the ?symbols help page for drawing circles

x <- c(2, 5, 7, 9, 12, 16, 18, 21)
y <- c(3, 6, 10, 13, 15, 19, 23, 25)
plot(x, y)
symbols(x=c(5,18), y=c(6,23), circles=rep(1,2), add=T, inches=F)

enter image description here

like image 119
MrFlick Avatar answered May 21 '23 14:05

MrFlick