Skip to contents

Applies ggplot2::expansion() to one or both axes, automatically detecting the correct scale type.

Usage

fmt_expand(plot, mult = 0, add = c(0, 0), axis = NULL)

Arguments

plot

A ggplot, patchwork, or list of ggplots.

mult

Multiplicative expansion factor.

add

Additive expansion (length-2 vector for lower/upper).

axis

"x", "y", or NULL (both).

Value

Same type as input.

Examples

library(ggplot2)
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point()
fmt_expand(p, mult = 0.05)

fmt_expand(p, add = c(0.5, 0), axis = "x")