label_date | R Documentation |
Re-export from the scales package.
Can be used to overwrite the default locale of date labels.
label_date_short()
only labels part of the dates, when they change,
i.e. year is only labelled when the year changes.
See scales::label_date()
and scales::label_date_short()
for more details.
label_date(format = "%Y-%m-%d", tz = "UTC", locale = NULL)
label_date_short(
format = c("%Y", "%b", "%d", "%H:%M"),
sep = "\n",
leading = "0",
tz = "UTC",
locale = NULL
)
format |
For For |
tz |
a time zone name, see |
locale |
Locale to use when for day and month names. The default
uses the current locale. Setting this argument requires stringi, and you
can see a complete list of supported locales with
|
sep |
Separator to use when combining date formats into a single string. |
leading |
A string to replace leading zeroes with. Can be |
A character vector of formatted dates.
library(tidyr)
library(outbreaks)
library(ggplot2)
# Change locale of date labels to Italian
sars_canada_2003 |> # SARS dataset from outbreaks
pivot_longer(starts_with("cases"), names_prefix = "cases_", names_to = "origin") |>
ggplot(aes(x = date, weight = value, fill = origin)) +
geom_epicurve(date_resolution = "week") +
scale_x_date(labels = label_date("%B %Y", locale = "it"), date_breaks = "1 month") +
scale_y_cases_5er() +
theme_classic()
# label_date_short()
sars_canada_2003 |> # SARS dataset from outbreaks
pivot_longer(starts_with("cases"), names_prefix = "cases_", names_to = "origin") |>
ggplot(aes(x = date, weight = value, fill = origin)) +
geom_epicurve(date_resolution = "week") +
scale_x_date(labels = label_date_short(), date_breaks = "1 week") +
scale_y_cases_5er() +
theme_classic()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.