I need to change the x-axis labels so they are words instead of numerals. Currently, the x-axis goes 1, 2, 3, etc. I would like it to go "Placement", "Fresh", etc.
trendplot <- function(timeseries, color, index, first = FALSE, w = 4, add_main = ""){
if (first) {
plot.ts(timeseries[, index], col = color, lwd = w,
ylim = c(-2, 2),
ylab = "Scaled Relative Abundance",
xlab = "Stage",
main = paste0("Trend Plots", add_main)) # gsub(".", " ", colnames(timeseries)[index], fixed = TRUE)
} else {
lines(timeseries[, index], col = color, lwd = w)
}
}
Update: This code works for what I wanted it be.
stages<-c('Placement','Fresh','Bloat One','Bloat Two','Post-Bloat One','Post-Bloat Two')
trendplot <- function(timeseries, color, index, first = FALSE, w = 4, add_main = ""){
if (first) {
plot.ts(timeseries[, index], col = color, lwd = w, axes = FALSE,
ylim = c(-2, 2),
ylab = "Scaled Measurement",
xlab = "Time Point",
main = paste0("Trend Plots", add_main)) # gsub(".", " ", colnames(timeseries)[index], fixed = TRUE)+
} else {
lines(timeseries[, index], col = color, lwd = w)
}
{axis(1, at=1:6, labels=stages, cex.axis=0.5)}
}