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.
Examples
center_limits(5)(c(3,8))
#> [1] 2 8
g <- ggplot(iris,
aes(Sepal.Width, Sepal.Length,
colour = log2(Petal.Width / Petal.Length))) +
geom_point() +
scale_colour_gradient2(limits = center_limits())