breaks_right | R Documentation |
This function generates a vector of of 'pretty'
breaks (using scales::breaks_pretty()
) that ends with
the upper limit provided and excludes any values that lie
outside the limits.
breaks_right(limits, n_breaks = 5, ...)
limits |
Length-two numeric or date vector |
n_breaks |
Number of breaks; passed to |
... |
Passed to |
Vector of breaks
# Can be used with numeric vectors
breaks_right(c(10, 30))
# Or date vectors
econ_dates <- c(min(ggplot2::economics$date),
max(ggplot2::economics$date))
breaks_right(econ_dates)
# Can be supplied directly to the `breaks` argument of
# `ggplot2::scale_*_continuous()`, but limits will include
# padding defined by `expand`
library(ggplot2)
ggplot(ggplot2::economics,
aes(x = date, y = unemploy)) +
geom_line() +
scale_x_date(breaks = breaks_right)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.