one_label: Annotate a single break on an axis with a label

Description Usage Arguments Examples

View source: R/ggplot2_helpers.R

Description

For use in the labels argument of ggplot2::scale_*_continuous

Usage

1
one_label(x, suffix = "ms", prefix = "", position = "last")

Arguments

x

Vector of axis breaks

suffix

A string attached to the end of the text. Defaults to "ms".

prefix

A string attached to the beginning of the text. Defaults to "".

position

Which label the annotation should go to. Either 'first' (bottom/left) or 'last' (top/right).

Examples

1
2
3
4
5
6
7
8
## Not run: 
my_plot <- ggplot(mtcars, aes(mpg, hp)) + geom_point()
my_plot + scale_y_continuous(labels = one_label)
my_plot + scale_y_continuous(labels = function(x) one_label(x, "%"))
my_plot + scale_y_continuous(labels = function(x) one_label(x, "%", position = "first"))
my_plot + scale_y_continuous(labels = function(x) one_label(x, prefix = "$"))

## End(Not run)

yjunechoe/junebug documentation built on July 9, 2021, 7:12 p.m.