labs_from_labels: Add ggplot axis labels from labels attribute

View source: R/report_plots.R

labs_from_labelsR Documentation

Add ggplot axis labels from labels attribute

Description

Add ggplot axis labels from labels attribute

Usage

labs_from_labels(gg)

Arguments

gg

a ggplot object

Value

a ggplot object

Examples


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


SimNPH documentation built on April 12, 2025, 9:13 a.m.