how to wrap text in ggplot for facet_grid labels
facet-grid, word-wrap
Solution
I found `labeller = labeller(label_wrap_gen(width = 2`... does not wrap.
Try
facet_grid(STRAT ~ protected_status,
labeller = label_wrap_gen(width = 2, multi_line = TRUE))
Problem
I have been searching how to wrap text. It seems there should be a way to use labeller = label_wrap_gen(3) but I keep getting an error: --- Error in margins(vars, margins) : unused argument (margins) Here is part of my code: ``` #simpson by protected status for domain FKNMS ggplot(data = fk_strata_abun_diversity, aes(x = YEAR)) + geom_point(aes(y = strata_simpson, color = "strata_simpson"),color = "blue") + geom_line(aes(y = strata_simpson, color = "strata_simpson"), color = "blue") + facet_grid(STRAT ~ protected_status, labeller = labeller(.rows = strata_names, .cols = protected_status_names), label_wrap_gen(width = 2)) + #error: in margins(vars, margins) : unused argument (margins) ?? labs(x = "Year", y = "Effective Number of Species") + ggtitle("Simpson Diveristy of Reef Fish in the Florida Keys by Strata") + theme(plot.title = element_text(hjust = 0.5, face = 'bold', size = 12)) + scale_x_continuous(limits = c(1999, 2016), breaks = c(1999:2016)) + scale_y_continuous(limits= c(0, 25), breaks = c(5,10,15,20,25)) ``` Thank you in advance for the help