breaks_pretty | R Documentation |
Uses default R break algorithm as implemented in pretty()
. This is
primarily useful for date/times, as extended_breaks()
should do a slightly
better job for numeric scales.
breaks_pretty(n = 5, ...)
n |
Desired number of breaks. You may get slightly more or fewer breaks that requested. |
... |
other arguments passed on to |
All breaks_()
functions return a function for generating breaks. These
functions takes, as their first argument a vector of values that represent
the data range to provide breaks for. Some will optionally take a second
argument that allows you to specify the number of breaks to recieve.
one_month <- as.POSIXct(c("2020-05-01", "2020-06-01"))
demo_datetime(one_month)
demo_datetime(one_month, breaks = breaks_pretty(2))
demo_datetime(one_month, breaks = breaks_pretty(4))
# Tightly spaced date breaks often need custom labels too
demo_datetime(one_month, breaks = breaks_pretty(12))
demo_datetime(one_month,
breaks = breaks_pretty(12),
labels = label_date_short()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.