Unable to plot a decent x-Axis in a time series plot using zoo

I use the R package zoo to plot a yearly time series of weekly averaged data. The problem is that my date variable (m.all$date) contains week numbers and these are plotted as x-Axis. What I would rather like to to is plot abbreviated months.

I can suppress the x-Axis in the plot using xaxt = "n" in the plot.zoo command, but cannot define a suitable x-Axis that plot abbreviated months instead.

I tried several variations of the axis.Date() commands without luck!

# Create zoo object for time series plot
z < - zoo(cbind(m.all$obsTPM, m.all$modTPM, m.all$refTPM), m.all$date) names(z) <- c("Observation","Model estimate", "Model reference") # Plot plot.zoo(z[, 1], type = "l", lwd = 1, col = "black", screens = c(1), xlab = "Date (2005)", ylim=c(m.all$obsTPM,m.all$modTPM, m.all$refTPM), ylab = "Concentration (pg m-3)", main = "Alert TPM: Observations vs. Model Estimates, Weekly Means") lines(z[, 2], lty = 5, lwd = 1, col = "blue") lines(z[, 3], lty = 3, lwd = 1, col = "red") legend("topleft", lty = c(1,5,3), legend = colnames(z), bty = "n", col = c("black","blue","red"), lwd = 1)

Published by

greg

Atmospheric chemistry researcher and university teacher. Data analysis/chemometrics specialist (PCA, PCR, Cluster analysis, SOM)

Leave a Reply

Your email address will not be published. Required fields are marked *