Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom date order in label_date_short() #363

Closed
CMKnott opened this issue Sep 23, 2022 · 1 comment
Closed

Allow custom date order in label_date_short() #363

CMKnott opened this issue Sep 23, 2022 · 1 comment

Comments

@CMKnott
Copy link

CMKnott commented Sep 23, 2022

Under the current build, the long labels must render as %b-%Y.

However, it would be good to specify that the long labels should go %Y-%b.

For example

# Data
df_test <- 
  tibble(
    date = seq(as.Date("2010-1-1"), as.Date("2012-1-1"), by = "months"),
    value = rnorm(n = length(date), mean = 10, sd = 1))

# Graph
df_test %>% 
  ggplot(aes(x = date, y = value)) +
  geom_line() + 
  scale_x_date(date_breaks = "1 month",
               labels = scales::label_date_short(format = c("%Y", "%b"))) + 
  theme(axis.text.x = element_text(angle = 0, hjust = 1))

This produces the graph

image

See that the long labels render %b-%Y. It would be good to specify that the long labels should go %Y-%b too.

@thomasp85
Copy link
Member

As can be read in the docs, the format argument should not be used to specify the order of the date format but rather the format to use for year, month, day, and hour respectively. There is no way to alter the order they are shown in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants