View source: R/month_label_cat_esp.r
month_label_cat_esp | R Documentation |
Converting English default date labels to calatan or spanish ones in ggplots. #'
month_label_cat_esp(
breaks,
language = c("catalan", "spanish"),
with_days = FALSE,
abbr = TRUE
)
breaks |
This argument is specified inside |
language |
Either 'catalan' or 'spanish'. By default catalan is selected. |
with_days |
Logical. If TRUE days are shown in the labels. By default is FALSE. |
abbr |
Logical. If TRUE full month labels are displayed. By default is FALSE. |
A character vector or a ScaleContinuousDate object for a ggplot.
library(dply);library(ggplot2)
## monthly sequence:
df1 <- data.frame(
x = seq.Date(lubridate::as_date('2020-01-01'),lubridate::as_date('2022-05-01'),
by = '1 month'),
y = rnorm(29) )
## plot
plot_1 <- ggplot(df1, aes(x,y))+ geom_line()
## catalan monthly labels
plot_1 +
scale_x_date(breaks = '3 month', # specify step width
labels = month_label_cat_esp )
## catalan monthly labels without abbreviate
plot_1 +
scale_x_date(breaks = '3 month',
labels = ~ month_label_cat_esp(.x, abbr = FALSE ) )
## daily sequence:
df2 <- tibble(
'z' = seq.Date(lubridate::as_date('2021-12-01'),lubridate::as_date('2022-01-15'),
by = '1 day'),
y= runif(length(z)) )
## spanish daily labels
ggplot(df2, aes(z,y))+
geom_line()+
scale_x_date(breaks = '3 days', # specify step width
labels = ~ month_label_cat_esp(.x,language = 'spanish',
with_days = TRUE) )
## extract a character vector of labels
ksnet::month_label_cat_esp( df2$z, language = 'spanish' )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.