Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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)
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.