Skip to contents

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 of col.

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 for colorby 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 (using oce::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 the zlim argument to oce::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 to gliderDebug. Setting debug=0 turns off this form of debugging, while higher values may yield more information, depending on the function. If one glider function calls another, it passes the value of debug but decreased by 1, which means that the value of debug 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 or which="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 use plot(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 with points(g[["longitude"]], g[["latitude"]] or similar. This method is more flexible than the present plot() function.

  • which=1 or which="p": time-series plot of pressure, produced with oce::oce.plot.ts().

  • which=2 or which="T": time-series plot of temperature , produced with oce::oce.plot.ts().

  • which=3 or which="S": time-series plot of salinity, produced with oce::oce.plot.ts().

  • which=4 or which="TS": temperature-salinity diagram, with dots for data produced with oce::plotTS().

  • which=5 or which="navState": ignored except for seaexplorer data, this means to plot a time-series of the navigation state, stored as the navState item within the payload1 element of the data slot. The meanings of the navState values for seaexplorer data are:

    • 105: glider is not navigating yet

    • 115: glider is surfacing, with ballast and centre of gravity being adjusted to put antenna out of the water

    • 116: glider is at the surface, acquiring a GPS signal, and communicating

    • 110: ballast and centre of mass are adjusted to cause glider to inflect downward

    • 100: ballast is in diving position; adjustments may be made to adjust pitch and heading

    • 118: target depth or altitude has been achieved, so ballast and centre of mass are adjusted to inflect glider upwards

    • 117: 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