# For a simple ctd object
library(oce)
data(ctd)
plotTS(ctd)
# For a section object (note the outlier!)
data(section)
plotTS(section)
# For an argo object
data(argo)
plotTS(handleFlags(argo))
# Oxygen-based colormap
marOrig <- par("mar") # so later plots with palettes have same margins
cm <- colormap(section[['oxygen']])
drawPalette(colormap=cm, zlab='Oxygen')
plotTS(section, pch=19, col=cm$zcol, mar=par('mar')) # the mar adjusts for the palette
# Station-based colormap
Tlim <- range(section[['temperature']], na.rm=TRUE)
Slim <- range(section[['salinity']], na.rm=TRUE)
cm <- colormap(seq_along(section[['latitude', 'byStation']]))
par(mar=marOrig) # same as previous plot
drawPalette(colormap=cm, zlab='Latitude')
plotTS(section, Tlim=Tlim, Slim=Slim, pch=NA, mar=par('mar'))
jnk <- mapply(
function(s, col) {
plotTS(s, col=col, add=TRUE, type='l')
},
section[['station']], col=cm$zcol)
# Add spiciness contours
data(ctd)
plotTS(ctd, eos="gsw") # MANDATORY so x=SA and y=CT
usr <- par("usr")
n <- 100
SAgrid <- seq(usr[1], usr[2], length.out=n)
CTgrid <- seq(usr[3], usr[4], length.out=n)
g <- expand.grid(SA=SAgrid, CT=CTgrid)
spiciness <- matrix(gsw::gsw_spiciness0(g$SA, g$CT), nrow=n)
contour(SAgrid, CTgrid, spiciness, col=2, labcex=1, add=TRUE)
Run the code above in your browser using DataLab