Returns a ggplot2 labeller that inserts a single line break into facet
strip labels, splitting at the last word boundary at or before width
characters. This is the facet equivalent of pm_gg_break(), which
breaks axis and other aesthetic labels on a plot.
pm_label_break(width)A labeller function suitable for the labeller argument of
ggplot2::facet_wrap() or ggplot2::facet_grid().
pm_gg_break(), pm_gg_break_aes() to break axis and aesthetic
labels on a plot.
library(ggplot2)
data <- data.frame(
x = rnorm(60),
y = rnorm(60),
grp = rep(c("Short label", "A much longer label for this group"), 30)
)
ggplot(data, aes(x, y)) +
geom_point() +
facet_wrap(~grp, labeller = pm_label_break(15))