Skip to content

Instantly share code, notes, and snippets.

@juanchiem
Last active August 13, 2022 10:29
Show Gist options
  • Save juanchiem/b44da13a3d72b308513c01998d72f5a4 to your computer and use it in GitHub Desktop.
Save juanchiem/b44da13a3d72b308513c01998d72f5a4 to your computer and use it in GitHub Desktop.
# the first argument gives expansion equal to its multiplication by limit range;
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
scale_x_continuous(limits = c(1, 7), expand = c(.1, 0))
# right position will be 7 + (7-1) * .1 = 7.6
# the second gives the absolute expansion added to both end of the axis:
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
scale_x_continuous(limits = c(1, 7), expand = c(0, 1))
# right position will be 7 + 1 = 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment