Function to ensure that a position scale is symmetric about 0

symmetric_range(range)

Arguments

range

range of the data

Value

symmetric range

Examples

library(ggplot2)
ggplot(mpg, aes(cty, hwy)) + 
geom_point() +
  scale_x_continuous(limits = symmetric_range)