When a label exceeds the maximum length as defined by the user, the function splits the text/label on the first space after the centre of the string. This is very useful for long labels in a plot

plot_label_splitter(label, maxlength)

Arguments

label

A character array (the label)

maxlength

When the label exceeds this length, it will be split into a two-line label

Details

The function can be easily applied to a data.frame by using e.g. sapply

Examples

plot_label_splitter("Exotic long label", 10)
#> [1] "Exotic long\nlabel"