I am creating time series plot for the following data:
# Creating data set
year <- c(rep(2018,4), rep(2019,4), rep(2020,4))
month_1 <- c(2, 3, 7, 8, 6, 10, 11, 12, 5, 7, 8, 12)
avg_dlt_calc <- c(10, 20, 11, 21, 13, 7, 10, 15, 9, 14, 16, 32)
data_to_plot <- data.frame(cbind(year,month_1,avg_dlt_calc ))
ggplot(data_to_plot, aes(x = month_1)) +
geom_line(aes(y = avg_dlt_calc), size = 0.5) +
scale_x_discrete(name = "months", limits = data_with_avg$month_1) +
facet_grid(~year, scales = "free")
I am ok with the plot itself, but x-axis labels are messed up:
How I can fix it?
It is ok not to have labels for missing months (for example, for 2018 it will be only 2,3,7,8 - so it will be clear, that there is data only for those months).