This is a limited function that is intended for quick views of a dataset. More serious analysis is best done by extracting data and using whatever graphical methods best suit the task at hand.
Usage
# S4 method for class 'glider'
plot(x, which, col = 1, colorby = NULL, colorbylim, debug, ...)
Arguments
- x
a [glider-class object.
- which
either an integer or character value specifying which style is to be used; see “Details”.
- col
colour to be used for lines or characters. Note that if
colorby
is provided, then it will be used for point plots, instead ofcol
.- colorby
character value, ignored for line plots, that names a data variable to be indicated on the plot through the colourization of individual plotted points (i.e.
type="p"
must be governing the plot forcolorby
to have an effect). For example, a form of a temperature section plot can be created by plotting glider depth versus time, coloured by temperature. For reference, a colour palette (usingoce::oceColorsTurbo()
is displayed to the right of the plot. See Example 3.- colorbylim
optional value, used only if
colorby
is provided, to set the limits of the colorizing limits. It does this by being provided as thezlim
argument tooce::colormap()
.- debug
an integer specifying whether debugging information is to be printed during processing. If this is not provided, then the value of
getOption("gliderDebug",0)
is used. The printing is done by a call togliderDebug
. Settingdebug=0
turns off this form of debugging, while higher values may yield more information, depending on the function. If oneglider
function calls another, it passes the value ofdebug
but decreased by 1, which means that the value ofdebug
controls not just the breadth of debugging, but also the depth.- ...
ignored.
Details
The form of the plot is set by the which
argument, as follows.
which=0
orwhich="map"
: plot a map of sampling locations. This can be quite slow with the default plot type (using points), so you may find it helpful to useplot(g, type="l")
to get a quick plot. If you want to change the view, e.g. expanding it so coastline are visible, start by drawing a coastline using the oce package, and then add dots withpoints(g[["longitude"]], g[["latitude"]]
or similar. This method is more flexible than the presentplot()
function.which=1
orwhich="p"
: time-series plot of pressure, produced withoce::oce.plot.ts()
.which=2
orwhich="T"
: time-series plot of temperature , produced withoce::oce.plot.ts()
.which=3
orwhich="S"
: time-series plot of salinity, produced withoce::oce.plot.ts()
.which=4
orwhich="TS"
: temperature-salinity diagram, with dots for data produced withoce::plotTS()
.which=5
orwhich="navState"
: ignored except for seaexplorer data, this means to plot a time-series of the navigation state, stored as thenavState
item within thepayload1
element of thedata
slot. The meanings of thenavState
values forseaexplorer
data are:105
: glider is not navigating yet115
: glider is surfacing, with ballast and centre of gravity being adjusted to put antenna out of the water116
: glider is at the surface, acquiring a GPS signal, and communicating110
: ballast and centre of mass are adjusted to cause glider to inflect downward100
: ballast is in diving position; adjustments may be made to adjust pitch and heading118
: target depth or altitude has been achieved, so ballast and centre of mass are adjusted to inflect glider upwards117
: glider is ascending, with controls being adjusted for desired pitch and heading
Lines and notes in the plot border indicate these states, both numerically and with phrases, as inferred by
navStateCodes()
.
Examples
library(oceglider)
# Example 1: various plot types, using defaults
directory <- system.file("extdata/sea_explorer/delayed_raw", package = "oceglider")
g <- read.glider.seaexplorer.realtime(directory, progressBar = FALSE)
plot(g, which = "p")
#> [1] "2019-07-19 15:12:10 UTC" "2019-07-19 18:02:08 UTC"
#> w: 14475
#> t[w]: 2019-07-19 18:02:08.088
#> p[w]: NA
plot(g, which = "S")
plot(g, which = "T")
plot(g, which = "TS")
plot(g, which = "map")
plot(g, which = "navState")
# Example 2: colour-code p by temperature, autoscaled
plot(g, which = "p", type = "p", pch = 20, colorby = "temperature")
#> [1] "2019-07-19 15:12:10 UTC" "2019-07-19 18:02:08 UTC"
#> w: 14475
#> t[w]: 2019-07-19 18:02:08.088
#> p[w]: NA
# Example 3: colour-code p by temperature, with a colour palette,
# and more aesthetic control, e.g. setting limits using quantiles.
temperature <- g[["temperature"]]
cm <- colormap(temperature,
zlim = quantile(temperature, c(0.01, 0.99), na.rm = TRUE),
col = oceColorsTurbo
)
par(mar = c(2, 3.5, 2, 4))
drawPalette(colormap = cm)
plot(g, which = "p", type = "p", col = cm$zcol, mar = c(2, 3.5, 2, 4), pch = 20)
#> [1] "2019-07-19 15:12:10 UTC" "2019-07-19 18:02:08 UTC"
#> w: 14475
#> t[w]: 2019-07-19 18:02:08.088
#> p[w]: NA