I have a graph with a hoover. In this I show a list of names. Sometimes this list is too long and I would like my hoover to split the names into several lines.
So the input for my hoover is this:
all_names = paste(unique(names_x), collapse = ', ')
And in 'text' I put this variable. How do I adjust this format to insert a max length of the line or something like that?
p <- ggplot(dataframe, aes(x=reorder(f_names,n_totaal), y=n,
fill=jaar %>% as.factor(),
text=c(paste0(n,": ",all_names))))+
geom_bar(stat="identity",
position=position_stack(reverse = TRUE)) +
coord_flip()+
reverse = TRUE,
zero_axis = "x")+
scale_y_continuous(breaks= pretty_breaks())
To clarify; the hoover is now 'Anna, Lisa, Bert, Otto, Max, Andreas, Kay, Michaella, Joost, Benny, Howard'. That is very lang and I would like the hoover to break automaticcaly after length X. Then the hoover would be:
'Anna, Lisa, Bert, Otto, Max, Andreas, Kay, Michaella, Joost, Benny, Howard'