add_facet_labels | R Documentation |
ggplot2
objectEnhances a ggplot2
plot by adding labels that describe
the faceting variables along the x and y axes.
add_facet_labels(p, xfacet_label = NULL, yfacet_label = NULL)
p |
( |
xfacet_label |
( |
yfacet_label |
( |
Returns grid
or grob
object (to be drawn with grid.draw
)
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.