小编Meg*_*eth的帖子

如何在 ggplot 中为 facet_grid 标签包装文本

我一直在寻找如何换行文本。似乎应该有一种方法可以使用 labeller = label_wrap_gen(3) 但我不断收到错误:---边距错误(vars,边距):未使用的参数(边距)

这是我的代码的一部分:

#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 …
Run Code Online (Sandbox Code Playgroud)

word-wrap facet-grid

5
推荐指数
1
解决办法
3823
查看次数

标签 统计

facet-grid ×1

word-wrap ×1