Hi, does any one know how i can manage to set a new line, if the discription is to long, as my example shows.
Thank you for your help!
Hi, does any one know how i can manage to set a new line, if the discription is to long, as my example shows.
Thank you for your help!
To do that you can use stringr::str_wrap()
function, which takes as argument a character vector and the position you want to place the line break "\n".
Here is a reproducible example using ggplot2.
df <- data.frame(label = c(
"This is a very long long long label to wrap in two lines",
"This another very long long long label to wrap in two lines",
"This is third long, very long long label to wrap in two lines"
),
value = c(500, 600, 800)
)
df %>%
ggplot(aes(x = value, y = str_wrap(label, 35))) +
geom_col()