colors = c("#ffc30f", "#ff5733", "#c70039", "#900c3f", "#581845") j=1 aloha <- read.csv("dataAloha.csv") aloha$date <- as.Date(aloha$date) pCO2 = aloha$pCO2 date = aloha$date month = as.numeric(format(date, "%m")) year = as.numeric(format(date, "%Y")) plot(month, pCO2, type="n", ylim=c(350, 410), xlab="Month", ylab=expression(paste("pCO"[2], " (", mu, "atm)")), main=("Monthly evolution of dissolved carbon dioxide, 2013-2017")) for (i in 2013:2017) { lines(month[year==i], pCO2[year==i], col=colors[j], lwd=1.5) j=j+1 } grid(col="lightblue4", lty="dotted") legend("topright", legend=c(2013:2017), col=colors, pch="--", box.col="#ffffff", bg="#ffffff", inset=.03)