5

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

这是我的代码的一部分:

#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))

预先感谢您的帮助

4

2 回答 2

6

我发现labeller = labeller(label_wrap_gen(width = 2......不换行。

尝试

facet_grid(STRAT ~ protected_status,
     labeller = label_wrap_gen(width = 2, multi_line = TRUE))
于 2017-10-16T14:07:11.853 回答
4

以下将适用于facet_grid()and facet_wrap()

facet_grid(labeller = labeller(facet_category = label_wrap_gen(width = 16)))

其中facet_category是要修改的构面变量,并设置换行前width的最大字符数。

multi_line仅当您在分面公式中指定了多个因素时才需要(例如~first + second

于 2018-12-06T02:00:29.063 回答