Hi, I have plotted a time series in R studio using the code:
PrecipDischarge.dat <- read.csv("PrecipDischargePreAndPost.csv") # precipitation and discharge time series from 2010 to 2022
precip <- PrecipDischarge.dat$Precipitation
precip
precip.ts <- ts(precip)
plot(precip.ts)
The above code produces the correct time series plot, but has x-axis labels as "0", "200", "400", "600", "800", 1000" (as shown in the attached figure) instead of "2010", "2011", "2012", "2013", "2014", 2015", "2016", "2017", "2018", "2019", "2020", "2021", and "2022".
I then removed the x-axis labels using the code:
plot(precip.ts, xaxt = 'n')
I am now trying to add axis labels to show the years "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", using the code:
axis(1:12, at = c("2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022"))
However, this code isn't adding any axis labels. Does anyone know what is going on here? How do I get the correct dates to display on my x-axis?
TIA