Skip to content

Instantly share code, notes, and snippets.

@paleolimbot
Created July 13, 2019 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paleolimbot/e25d8edd651dad08e8e5e24dcbd3570b to your computer and use it in GitHub Desktop.
Save paleolimbot/e25d8edd651dad08e8e5e24dcbd3570b to your computer and use it in GitHub Desktop.
library(ggplot2)
symmetric_range <- function(range) {
max_abs <- max(abs(range))
c(-max_abs, max_abs)
}
ggplot(mpg, aes(cty, hwy)) +
geom_point() +
scale_x_continuous(limits = symmetric_range)
@paleolimbot
Copy link
Author

library(ggplot2)

symmetric_range <- function(range) {
  max_abs <- max(abs(range))
  c(-max_abs, max_abs)
}

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

Created on 2019-07-12 by the reprex package (v0.2.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment