6

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)

5
  • Do you mean circles with the same radius? Commented May 13, 2015 at 3:04
  • It's not clear if you mean one circle encompassing both points, or 2 circles - one around each point. Commented May 13, 2015 at 3:06
  • Thanks for asking for clarification. I mean separate circles (1 around each point) of a defined radius of the same size. Commented May 13, 2015 at 3:15
  • To me, defined radius =/= same radius, i.e. you can define different radius or the same radius. Commented May 13, 2015 at 3:20
  • Ah, thank-you again. I mean circles of the same radius which I have defined. Commented May 13, 2015 at 3:24

2 Answers 2

7

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @MrFlick. This is exactly what I was looking for. I also discovered the circles can be coloured by using symbols(x=c(5,18), y=c(6,23), circles=rep(1,2), add=T, inches=F, fg = "red")
5

You can use the symbols function in base R, where the size vector is the radius you want around each point.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.