labs_from_labels | R Documentation |
Add ggplot axis labels from labels attribute
labs_from_labels(gg)
gg |
a ggplot object |
a ggplot object
library("ggplot2")
test <- mtcars
# add a label attribute
attr(test$cyl, "label") <- "cylinders"
# plot witht the variable names as axis titles
gg1 <- ggplot(test, aes(x=wt, y=cyl)) +
geom_point()
gg1
# add labels where defined in the attribute
gg2 <- ggplot(test, aes(x=wt, y=cyl)) +
geom_point()
gg2 <- labs_from_labels(gg2)
gg2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.