I'm trying to get rid of labels overlapping as you see below.
reprex:
library(tidyverse)
library(ggrepel)
tibble(
n = c(1, 1, 1, 2, 50, 46),
label = paste0(c(1, 1, 1, 2, 50, 46), "%")) %>%
ggplot(aes(x = "", y = n)) +
geom_bar(width = 1, stat = "identity") +
geom_text(aes(x = 1.6, label = label),
position = position_stack(vjust = 0.5)) +
coord_polar("y")
result (undesired overlaps):
desired output:
I tried ggrepel
but result is not desired, no lines from labels to circle border are drawn.
tibble(
n = c(1, 1, 1, 2, 50, 46),
label = paste0(c(1, 1, 1, 2, 50, 46), "%")) %>%
ggplot(aes(x = "", y = n)) +
geom_bar(width = 1, stat = "identity") +
ggrepel::geom_text_repel(aes(x = 1.6, label = label),
position = position_stack(vjust = 0.5)) +
coord_polar("y")
result (I don't know how to add lines or arrows).