How do I outline the percentage labels for greater visibility in the graph?, help

cbrf_2010_2021 %>%
ggplot(aes(x = PRECIO_CAT, fill = HAS_cat)) +
geom_bar(position = "stack") +
stat_count(aes(label = paste0(round((..count..)/sum(..count..) * 100, 2), "%")),
geom = "text",
position = position_stack(vjust = 0.5),
size = 3,
color = "white",
fontface = "bold")

How do I fix my code so that instead of displaying "0-1mio", "1-10mio", "10mio+") it displays like this: "0 - $1,000,000", "$1,000,000 - $10,000,000", and so on

cbrf_2010_2021$price_CAT = factor(cut(cbrf_2010_2021$price, breaks = c(0, 1e6, 1e7,max(cbrf_2010_2021$price)), right = TRUE), ordered = TRUE)

levels(cbrf_2010_2021$price_CAT) <- c("0-1mio", "1-10mio", "10mio+")

cbrf_2010_2021 %>% ggplot(aes(x = price_CAT, fill = HAS_cat)) +
geom_bar(position = "stack")

For the outlined text, you could try:

For the second bit, it would help if you provided a reproducible example:

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.