ggplot(mpg, aes(displ, hwy)) +
geom_point() +
facet_wrap(c("cyl", "drv"), labeller = labeller(.multi_line = FALSE))
我想用标签中的空格替换逗号。
请您参考如下方法:
你可以做这样的事情 -
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
facet_wrap(c("cyl", "drv"), labeller = function (labels) {
labels <- lapply(labels, as.character)
a <- do.call(paste, c(labels, list(sep = ",")))
list(gsub("\\,"," ",a))
})
备注 - 我们可以使用此方法传递任何自定义函数。
输出-