add_facet_labels {teal.modules.general} | R Documentation |
Add labels for facets to a ggplot2
object
Description
Enhances a ggplot2
plot by adding labels that describe
the faceting variables along the x and y axes.
Usage
add_facet_labels(p, xfacet_label = NULL, yfacet_label = NULL)
Arguments
p |
( |
xfacet_label |
( |
yfacet_label |
( |
Value
Returns grid
or grob
object (to be drawn with grid.draw
)
Examples
library(ggplot2)
library(grid)
p <- ggplot(mtcars) +
aes(x = mpg, y = disp) +
geom_point() +
facet_grid(gear ~ cyl)
xfacet_label <- "cylinders"
yfacet_label <- "gear"
res <- add_facet_labels(p, xfacet_label, yfacet_label)
grid.newpage()
grid.draw(res)
grid.newpage()
grid.draw(add_facet_labels(p, xfacet_label = NULL, yfacet_label))
grid.newpage()
grid.draw(add_facet_labels(p, xfacet_label, yfacet_label = NULL))
grid.newpage()
grid.draw(add_facet_labels(p, xfacet_label = NULL, yfacet_label = NULL))
[Package teal.modules.general version 0.3.0 Index]