Skip to contents

Create a ggplot2::ggproto object that inherits from super, designed to be a ggplot2 scale for measure objects that adds units to the aesthetic label.

Usage

enmeasure_scale(super)

Arguments

super

a ggplot2::Scale object returned from a scale_*() function like ggplot2::scale_x_continuous()

Value

A ggplot2::Scale object

Details

make_title() is redefined to return a formula derived from super$make_title() and units. See plot_math().

transform() is redefined to set units to units(x) and pass a plain double to super$transform().

Examples

library(ggplot2)
p <- ggplot(mpg, aes(measure(displ, "L"))) + geom_histogram()
s <- scale_x_continuous("Engine displacement")
p + enmeasure_scale(s)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.