center_limits: Center limits

View source: R/conveniences.R

center_limitsR Documentation

Center limits

Description

This a function factory that allows the centering of scales around a certain value while still including all values. Convenient for centering log2 fold change limits around zero.

Usage

center_limits(around = 0)

Arguments

around

A numeric of length 1 indicating around which value to center the limits.

Value

A function that takes limits and returns expanded limits centered at the around argument.

Examples

center_limits(5)(c(3,8))

g <- ggplot(iris,
            aes(Sepal.Width, Sepal.Length,
                colour = log2(Petal.Width / Petal.Length))) +
  geom_point() +
  scale_colour_gradient2(limits = center_limits())

ggh4x documentation built on May 29, 2024, 6:47 a.m.