Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This is how to make the x or y axes only show integer values in a programmatic and scalable fashion.
# A function factory for getting integer y-axis values.
integer_breaks <- function(n = 5, ...) {
fxn <- function(x) {
breaks <- floor(pretty(x, n, ...))
names(breaks) <- attr(breaks, "labels")
plot + scale_y_continuous(breaks = integer_breaks())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment