| scale_x_dt | R Documentation |
Wrapper for ggplot2::scale_x_date that generates labels for data variable on x-axis based on input data.
scale_x_dt(
df,
x,
break_by = "year",
round_unit = "year",
labels = scales::date_format("'%y"),
...
)
df |
data set used for plotting |
x |
date variable mapped to x-axis |
break_by |
a character string specifying a time unit to use for axis breaks |
round_unit |
a character string specifying a time unit or a multiple of a unit to be rounded to for the axis breaks.
Valid base units are |
labels |
format to use for displaying labels |
... |
additional arguments passed to |
A ggplot2 date scale object created by
ggplot2::scale_x_date().
Saannidhya Rawat
library(ggplot2)
# use default ggplot2 scale
bcat_plt_line(df = economics,
x = date,
y = unemploy,
y_ref = 10000)
# use scale_x_dt to break by every 5 years
bcat_plt_line(df = economics,
x = date,
y = unemploy,
y_ref = 10000,
x_scale = scale_x_dt(economics, date, round_unit = "5 years"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.