Skip to content

YearWeek and scale_x_yearweek with 1 year gaps lead to wrong x axis. #293

Description

@USMortality

YearWeek and scale_x_yearweek with 1 year gaps, lead to wrong x axis. See here in this example, 2020 is duplicated twice and every year, thereafter is offset by 1...

I think this has todo with the extra week 53 of 2020...
What can I do to fix this?

plot

df <- as_tibble(data.frame(
  x = seq(from = mdy("1/1/2019"), to = mdy("1/1/2022"), by = "week"),
  y = runif(157, min = 0, max = 25)
)) %>% mutate(x = yearweek(x))

ggplot(df, aes(x = x, y = y)) +
  geom_line(color = "#5383EC", linewidth = 1) +
  scale_x_yearweek(date_breaks = "1 year", date_labels = "%Y")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions