 # Creative bubble and thread plot using ggplot ?

Basic logic, circle broadens as the time increases.

More than the number of years: More the radius of the circle while the thread connecting the bubble will be equal.

Can we build something like this using ggplot ?
If donut can be built via ggplot, this also could be built. Isn't it ?

e.g.
df = data.frame( x = radius, y = number of years ) ..... !!!!

How about something like the code below? I've used `geom_point` to create the circles, but you can also take a look at `geom_circle` from the `ggforce` package if you want more direct control over the circle radii.

``````library(tidyverse)

d = tibble(time=seq(6, 18, 3),
text = paste(time/12, ifelse(time/12==1, "year", "years")),
x=1)

p1 = ggplot(data=d, aes(x=x, y=time)) +
geom_line() +
geom_point(shape=21, aes(size=time), fill=hcl(120,50,90)) +
geom_text(aes(label=str_wrap(text, 8)), size=3) +
scale_size_continuous(range=c(10,20)) +
coord_fixed(ratio=1/100) +
scale_y_continuous(expand=expand_scale(mult=c(0.1,0.1))) +
theme_void() +
guides(size=FALSE)

p2 = ggplot(data=d, aes(x=x, y=time)) +
geom_line() +
geom_point(shape=21, aes(size=time), fill=hcl(120,50,90)) +
geom_point(shape=21, aes(size=0.3*time), fill="white") +
geom_text(aes(label=str_wrap(text, 8)), size=3) +
scale_size_continuous(range=c(10,20)) +
coord_fixed(ratio=1/100) +
scale_y_continuous(expand=expand_scale(mult=c(0.1,0.1))) +
theme_void() +
guides(size=FALSE)

gridExtra::grid.arrange(p1, p2, ncol=2)
`````` 5 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.