plot,argoFloats-method | R Documentation |
The action depends on the type
of the object, and
this is set up by the function that created the object;
see “Details”. These are basic plot styles, with
somewhat limited scope for customization. Since the data with
argoFloats objects are easy to extract, users should
not find it difficult to create their own plots to meet a
particular aesthetic. See “Examples” and Kelley et al. (2021)
for more plotting examples.
## S4 method for signature 'argoFloats'
plot(
x,
which = "map",
bathymetry = argoDefaultBathymetry(),
geographical = 0,
xlim = NULL,
ylim = NULL,
xlab = NULL,
ylab = NULL,
type = "p",
cex = par("cex"),
col = par("fg"),
pch = par("pch"),
bg = par("bg"),
eos = "gsw",
mapControl = NULL,
profileControl = NULL,
QCControl = NULL,
summaryControl = NULL,
TSControl = NULL,
debug = 0,
...
)
x |
an |
which |
a character value indicating the type of plot. The possible
choices are |
bathymetry |
an argument used only if |
geographical |
flag indicating the style of axes
for the |
xlim , ylim |
numerical values, each a two-element vector, that
set the |
xlab |
a character value indicating the name for the horizontal axis, or
|
ylab |
as |
type |
a character value that controls the line type, with |
cex |
a character expansion factor for plot symbols, or |
col |
the colour to be used for plot symbols, or |
pch |
an integer or character value indicating the type of plot symbol,
or |
bg |
the colour to be used for plot symbol interior, for |
eos |
a character value indicating the equation of state to use
if |
mapControl |
a list that permits particular control of the |
profileControl |
a list that permits control of the |
QCControl |
a list that permits control of the |
summaryControl |
a list that permits control of the |
TSControl |
a list that permits control of the |
debug |
an integer specifying the level of debugging. |
... |
extra arguments passed to the plot calls that are made within this function. |
The various plot types are as follows.
For which="map"
, a map of profile locations is created if subtype
is equal to cycles, or a rectangle highlighting the trajectory of a
float ID is created when subtype is equal to trajectories. This
only works if the type
is "index"
(meaning that x
was created
by getIndex()
or a subset of such an object, created with
subset,argoFloats-method()
), or argos
(meaning that
x
was created with readProfiles()
. The plot range is
auto-selected. If the ocedata
package
is available, then its coastlineWorldFine
dataset is used to draw
a coastline (which will be visible only if the plot region
is large enough); otherwise, if the oce
package is available, then its
coastlineWorld
dataset is used.
The bathymetry
argument controls whether (and how) to draw a map underlay
that shows water depth. There are three possible values for bathymetry
:
FALSE
(the default, via argoDefaultBathymetry()
), meaning not to draw bathymetry;
TRUE
, meaning to draw bathymetry as an
image, using data downloaded with oce::download.topo()
.
Example 4 illustrates this, and also shows how to adjust
the margins after the plot, in case there is a need to add
extra graphical elements using points()
, lines()
, etc.
A list with items controlling both the bathymetry data and its representation in the plot (see Example 4). Those items are:
source
, a mandatory value that is either
(a) the string "auto"
(the default) to use
oce::download.topo()
to download the data
or (b) a value returned by oce::read.topo()
.
contour
, an optional logical value (with FALSE
as the default)
indicating whether to represent
bathymetry with contours (with depths of 100m, 200m, 500m shown,
along with 1km, 2km up to 10km), as opposed to an image;
colormap
, ignored if contour
is TRUE
,
an optional value that is either the string "auto"
(the default)
for a form of GEBCO colors computed with
oce::oceColorsGebco()
, or a value computed with oce::colormap()
applied to the bathymetry data; and
palette
, ignored if contour
is TRUE
,
an optional logical value (with TRUE
as the default)
indicating whether to draw a depth-color
palette to the right of the plot.
Note that the default value for bathymetry
is set by a call
to argoDefaultBathymetry()
, and that this second function can only handle possibilities
1 and 2 above.
For which="profile"
, a profile plot is created, showing the variation of
some quantity with pressure or potential density anomaly, as specified by the
profileControl
argument.
For which="QC"
, two time-series panels are shown, with
time being that recorded in the individual profile in the dataset.
An additional argument named parameter
must be given, to name the
quantity of interest. The function only works if x
is an
argoFloats
object created with readProfiles()
.
The top panel shows the percent of data flagged with codes
1 (meaning good data), 2 (probably good), 5 (changed)
or 8 (estimated), as a function of time (lower axis) and
(if all cycles are from a single Argo float)
cycle number (upper axis, with smaller font).
Thus, low values on the top panel reveal
profiles that are questionable. Note that if all of data at a given time
have flag 0, meaning not assessed, then a quality of 0 is plotted at that
time. The bottom panel shows the mean value of the parameter in question
regardless of the flag value.
For which="summary"
, one or more time-series panels are shown
in a vertical stack. If there is only one ID in x
, then the cycle
values are indicated along the top axis of the top panel. The choice
of panels is set by the summaryControl
argument.
For which="TS"
, a TS plot is created, by calling plotArgoTS()
with the specified x
, xlim
, ylim
, xlab
, ylab
,
type
, cex
, col
, pch
, bg
, eos
, and TSControl
,
along with debug-1
. See the help for plotArgoTS()
for how these parameters are interpreted.
None (invisible NULL).
Dan Kelley and Jaimie Harbin
Carval, Thierry, Bob Keeley, Yasushi Takatsuki, Takashi Yoshida, Stephen Loch,
Claudia Schmid, and Roger Goldsmith. Argo User's Manual V3.3. Ifremer, 2019.
doi:10.13155/29825
Kelley, D. E., Harbin, J., & Richards, C. (2021). argoFloats: An R package for analyzing Argo data. Frontiers in Marine Science, (8), 636922. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3389/fmars.2021.635922")}
# Example 1: map profiles in index
library(argoFloats)
data(index)
plot(index)
# Example 2: as Example 1, but narrow the margins and highlight floats
# within a circular region of diameter 100 km.
oldpar <- par(no.readonly=TRUE)
par(mar=c(2, 2, 1, 1), mgp=c(2, 0.7, 0))
plot(index)
lon <- index[["longitude"]]
lat <- index[["latitude"]]
near <- oce::geodDist(lon, lat, -77.06, 26.54) < 100
R <- subset(index, near)
points(R[["longitude"]], R[["latitude"]],
cex=0.6, pch=20, col="red")
par(oldpar)
# Example 3: TS of a built-in data file.
f <- system.file("extdata", "SR2902204_131.nc", package="argoFloats")
a <- readProfiles(f)
oldpar <- par(no.readonly=TRUE)
par(mar=c(3.3, 3.3, 1, 1), mgp=c(2, 0.7, 0)) # wide margins for axis names
plot(a, which="TS")
par(oldpar)
# Example 4: map with bathymetry. Note that par(mar) is adjusted
# for the bathymetry palette, so it must be adjusted again after
# the plot(), in order to add new plot elements.
# This example specifies a coarse bathymetry dataset that is provided
# by the 'oce' package. In typical applications, the user will use
# a finer-scale dataset, either by using bathymetry=TRUE (which
# downloads a file appropriate for the plot view), or by using
# an already-downloaded file.
data(topoWorld, package="oce")
oldpar <- par(no.readonly=TRUE)
par(mar=c(2, 2, 1, 2), mgp=c(2, 0.7, 0)) # narrow margins for a map
plot(index, bathymetry=list(source=topoWorld))
# For bathymetry plots that use images, plot() temporarily
# adds 2.75 to par("mar")[4] so the same must be done, in order
# to correctly position additional points (shown as black rings).
par(mar=par("mar") + c(0, 0, 0, 2.75))
points(index[["longitude"]], index[["latitude"]],
cex=0.6, pch=20, col="red")
par(oldpar)
# Example 5. Simple contour version, using coarse dataset (ok on basin-scale).
# Hint: use oce::download.topo() to download high-resolution datasets to
# use instead of topoWorld.
oldpar <- par(no.readonly=TRUE)
par(mar=c(2, 2, 1, 1))
data(topoWorld, package="oce")
plot(index, bathymetry=list(source=topoWorld, contour=TRUE))
par(oldpar)
# Example 6. Customized map, sidestepping plot,argoFloats-method().
lon <- topoWorld[["longitude"]]
lat <- topoWorld[["latitude"]]
asp <- 1/cos(pi/180*mean(lat))
# Limit plot region to float region.
xlim <- range(index[["longitude"]])
ylim <- range(index[["latitude"]])
# Colourize 1km, 2km, etc, isobaths.
contour(x=lon, y=lat, z=topoWorld[["z"]], xlab="", ylab="",
xlim=xlim, ylim=ylim, asp=asp,
col=1:6, lwd=2, levels=-1000*1:6, drawlabels=FALSE)
# Show land
data(coastlineWorldFine, package="ocedata")
polygon(coastlineWorldFine[["longitude"]],
coastlineWorldFine[["latitude"]], col="lightgray")
# Indicate float positions.
points(index[["longitude"]], index[["latitude"]], pch=20)
# Example 7: Temperature profile of the 131st cycle of float with ID 2902204
a <- readProfiles(system.file("extdata", "SR2902204_131.nc", package="argoFloats"))
oldpar <- par(no.readonly=TRUE)
par(mfrow=c(1, 1))
par(mgp=c(2, 0.7, 0)) # mimic the oce::plotProfile() default
par(mar=c(1,3.5,3.5,2)) # mimic the oce::plotProfile() default
plot(a, which="profile")
par(oldpar)
# Example 8: As Example 7, but showing temperature dependence on potential density anomaly.
a <- readProfiles(system.file("extdata", "SR2902204_131.nc", package="argoFloats"))
oldpar <- par(no.readonly=TRUE)
par(mgp=c(2, 0.7, 0)) # mimic the oce::plotProfile() default
par(mar=c(1,3.5,3.5,2)) # mimic the oce::plotProfile() default
plot(a, which="profile", profileControl=list(parameter="temperature", ytype="sigma0"))
par(oldpar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.