Aligning four 'nested' circles along their bottom edges in R

Viewed 97

I am trying to create a visual that nests four circles as so:

nestedcircles

The size of the circle depends on a ratio/numeric value relative to the largest circle.

I found this post which seems to provide a solution for two aligned circles: Bubble Chart with bubbles aligned along their bottom edges

However, I am a complete newbie to R and not sure how to proceed to achieve the desired four aligned circles.

Sample input data:

d <- read.table(text = "circle:x
Circle1:340000
Circle2:5000
Circle3:1100
Circle4:340", header = TRUE, sep = ":")

Desired Output of four aligned circles based on input numbers:

nestedcircles

1 Answers

Convert area to radius, then use ggforce to draw circles:

library(ggforce)

#convert area to R
d$r <- sqrt(d$x / pi)
d$x0 <- max(d$r) / 2
d$y0 <- d$r

ggplot(d, aes(x0 = x0, y0 = y0, r = r, fill = circle)) +
  geom_circle() +
  theme_void()

enter image description here

Related