1

If I had a two sets of coordinates, with x and y representing circle centers and the size representing circle radius, how would I draw circles with them in ggplot2? I saw this question but it's about drawing a single circle I can't find a way to replicate it using a scatter plot.

Example data:

         x           y     sizes
  0.95285914  0.06596914 0.8868900
  -1.59822942  0.71052036 2.3087498
   0.39216559  0.58428603 0.1921204
   0.16559318 -0.99303562 1.1586288
  -0.43047728 -0.96649463 0.5360174
  -0.73746484 -0.21143717 0.5260277
   0.58779207  0.08073626 0.5070558
   0.74936811  0.54462816 0.2047399
  -0.01587290 -0.14835109 0.1324782
 -0.06573365  0.33317857 0.3989122
0

1 Answer 1

5
library(ggplot2)
library(ggforce)

dat = read.table(text="        x           y     sizes
  0.95285914  0.06596914 0.8868900
                 -1.59822942  0.71052036 2.3087498
                 0.39216559  0.58428603 0.1921204
                 0.16559318 -0.99303562 1.1586288
                 -0.43047728 -0.96649463 0.5360174
                 -0.73746484 -0.21143717 0.5260277
                 0.58779207  0.08073626 0.5070558
                 0.74936811  0.54462816 0.2047399
                 -0.01587290 -0.14835109 0.1324782
                 -0.06573365  0.33317857 0.3989122", header=TRUE)

ggplot(dat, aes(x0=x, y0=y, r=sizes)) + 
  geom_circle() + coord_equal() + theme_classic()

enter image description here

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

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.