I have a bar plot that has one very long legend element. I tried to use str_wrap
but it didn't work. My x
is not the issue, but rather the fill
values. Can someone help me? How can I adapt the str_wrap
to a plot using the fill aesthetics?
Some example data:
sex <- c(1, 1, 3, 1, 2, 2, 4, 1, 2, 2, 1, 1)
profession <- c("a", "a", "a", "b", "b", "b", "c", "c", "c", "d", "d", "d")
df <- data.frame(sex, profession)
My code:
ggplot(dat_sexpermedia_journalist,
mapping = aes(x = profession, fill = sex)) +
geom_bar() +
scale_fill_brewer(palette = "Greens") +
labs(x = "professions",
y = "count", fill = "sex") +
theme_minimal(base_size = 12) +
theme(legend.position = "bottom")