How can I change the (all) label given by facet_grid
to the strip text if margins = ...
?
Here is an example:
ggplot(mtcars, aes(mpg, wt)) + geom_point() +
facet_grid(am ~ cyl, margins = "cyl")
How can I make (all)
say FOO
How can I change the (all) label given by facet_grid
to the strip text if margins = ...
?
Here is an example:
ggplot(mtcars, aes(mpg, wt)) + geom_point() +
facet_grid(am ~ cyl, margins = "cyl")
How can I make (all)
say FOO
You can use the labeller
parameter of facet_grid()
. This is a function that takes two arguments, the variable and value. You can define your own:
facet_labels <- function(variable, value) {
labels <- as.character(value)
labels[labels == '(all)'] <- 'FOO'
return (labels)
}
ggplot(mtcars, aes(mpg, wt)) + geom_point() +
facet_grid(am ~ cyl, margins = "cyl", labeller = facet_labels)