I've had an issue as old as time when creating donut/pie charts in R (yes, I know...). The problem is that when using coord_polar()
, white space is is created on the top and bottom of charts. Since I don't fully understand why this is the case I've been trying to remedy it with theme()
attributes to avail. Ultimately I'm looking for the ability of my plots to have this current whitespace be customizable to my choosing.
Here is a reproducible example that produces the following plot:
set.seed(42069)
data.frame("x" = sample(letters[1:5], 800, replace = T)) %>%
count(x) %>%
mutate("total" = sum(n),
"percent" = n/total) %>%
ggplot(aes(x = 2, y = percent, fill = x))+
coord_polar(theta = "y", start = 0)+
geom_bar(stat = "identity")
Hard to see, but there is a white background on the top and the bottom (hence the spacing from the image seen in this chunk of text).