library(tidyverse)
df <- data.frame(date = as.Date(c("2017-12-01", "2018-01-01", "2018-02-01",
"2018-03-01", "2018-04-01", "2018-05-01",
"2018-06-01", "2018-07-01", "2018-08-01",
"2018-09-01", "2018-10-01", "2018-11-01")),
value = c(0.567859562, 0.514907158, 0.035399304, 0.485728823,
0.925127361, 0.237531067, 0.301930968, 0.133373326,
0.082275426, 0.464255614, 0.2366749, 0.652084264))
ggplot(df, aes(date, value)) +
geom_col() +
scale_x_date(date_breaks = "1 month",
date_labels = "%b") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.3))
I want to maintain my plot shown below, exactly as is, with two exceptions. I want to remove the first Nov on the x-axis label and the last Dec on the x-axis label. I added coord_cartesian(xlim = as.Date(c("2017-12-01", "2018-11-01"))) to my code chunk above, but this eliminates the 'blank space' padding at either end of my x-axis.
How do I simply tell ggplot to delete the text of the first and last x-axis labels? This would be the first Nov and the last Dec. Note that these do not exists in my df data frame at all so dplyr filters probably won't work.


