0

I want to add a specific date break in x axis to improve readability and to highlight important dates.

I have created a custom date vector, but this also adds gridlines which I do not want. Is there another way to do this?

data |> 
  ggplot(aes(x = date, y = n)) + 
  geom_col() +
  scale_x_date(breaks = as_date(c("2022-08-01", "2022-08-08", "2022-08-15", "2022-08-17", "2022-08-22", "2022-08-29")),
              date_labels = "%d %b")

enter image description here

1 Answers1

0

Having some data would help but try:

data |> 
  ggplot(aes(x = date, y = n)) + 
  geom_col() +
  scale_x_date(breaks = as_date(c("2022-08-01", "2022-08-08", "2022-08-15", "2022-08-17", "2022-08-22", "2022-08-29")),
              date_labels = "%d %b") +
theme(element_blank())

There are a number of ways to suppress/change gridlines and lots of questions on here that address this. A start: Remove grid, background color, and top and right borders from ggplot2

dandrews
  • 967
  • 5
  • 18