plotMO2: Plot oxygen uptake values as a function of time.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/plotMO2.R

Description

Wrapper function for plot and makeO2lab to produce plots of oxygen uptake as a function of time with better looking axis labels.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
plotMO2(
  x,
  y,
  mo2 = "dotital",
  o2 = "umol",
  t = "hr",
  m = "kg",
  showO2 = F,
  Xlab = "Time (month-day)",
  ...
)

Arguments

x

A vector or a column from a data frame representing time, typically in POSIXct or numeric (hours, days). POSIXct and hours are compatible with drawNights.

y

A vector or a column from a data frame representing oxygen uptake.

mo2

Selects the formatting of MO2, such as dotital (adds a dot on italics M to express a rate), dot, ital or plain. Used to call makeO2lab.

o2

Oxygen units, either mg, ug (gives microg), mmol, umol (gives micromol), ml or mL. Used to call makeO2lab.

t

Time unit, either hr or min. Used to call makeO2lab.

m

Mass unit for the animal, either kg, g or mg. Used to call makeO2lab.

showO2

Logical, to hide or show O2 after the oxygen unit. Used to call makeO2lab.

Xlab

A character string to label the x-axis of the plot. Default is "Time (month-day)".

...

Additional parameters that plot can handle.

Details

Produces a plot which the user could easily reproduce by calling makeO2lab and plot. A call to drawNights can enhance the plot.

Value

A plot.

Author(s)

Denis Chabot, Institut Maurice-Lamontagne, Department of Fisheries and Oceans

See Also

plot, par, drawNights, makeO2lab

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
StartD = as.POSIXct("2016-05-05 07:00")
EndD = as.POSIXct("2016-05-12 08:00")
Y = 1:5
X = seq(StartD, EndD, length.out = 5)
plotMO2(X, Y, mgp=c(2,0.5,0))

# with real data
data(codSDA)
plotMO2(codSDA$DateTime, codSDA$MO2cor, mgp=c(2,0.5,0))

# a more complex use of plotMO2
data(codSDA)
# remove bad R2s
minR2 = 0.96
codSDA = subset(codSDA, r2 >= minR2)
# There was a sham-feeding 25.65 h before feeding. On average the
# sham-feeding increased MO2 for about 10 h.
# This period, as well as the period after the meal and during the period
# when the fist was first placed into the respirometer should be removed
# before calculating SMR
# This fish took a long time to calm down, the acclimation period was set
# to 24 h
start = -97.22  # first MO2
sham = -25.65   # time of sham-feeding
acclim = 24     # nb of hours to exclude because of handling stress, this fish took a long time to calm down
sham.acclim = 10  # nb of hours after sham-feeding with elevated MO2
# instead of creating a subset of the data, as in an example of
# calcSMR, we'll store indices instead
smr.ind =  ((codSDA$Logtime_hr >= (start + acclim) &
             codSDA$Logtime_hr < sham ) | (codSDA$Logtime_hr >=
             (sham + sham.acclim) & codSDA$Logtime_hr < 0))
codSDA$pch = ifelse(smr.ind, 1, 15)
codSDA$cex = ifelse(smr.ind, 1, 0.7)
def.par <- par(no.readonly = TRUE) # save default, for resetting...
par(mar=c(3.1,3.3,0.2,0.2), mgp=c(1.8,0.5,0))
plotMO2(codSDA$DateTime, codSDA$MO2cor, mgp=c(2,0.5,0), pch=codSDA$pch,
        cex=codSDA$cex)
smr = calcSMR(codSDA$MO2cor[smr.ind])
abline(h=c(smr$mlnd, smr$quant[4], smr$low10pc),
       col=c("black", "blue", "red"))
legend("topright",
    c("used for SMR", "not used for SMR", "MLND", "q_0.2", "low10pc"),
    pch=c(15, 1,NA, NA, NA), pt.cex=c(0.7, 1,1,1,1),
    lty=c(0,0,1,1,1),
    col=c("black", "black", "black", "blue", "red"),
    bty="n")
attr(codSDA$DateTime, "tzone") = "EST"  # to force the use of the EST time
                                        # zone, where the fish were studied
StartD = codSDA$DateTime[1]
EndD = codSDA$DateTime[nrow(codSDA)]
Coords = par("usr")
drawNights(StartD, EndD, Site=Sites$IML, TimeZone=myTZs$IMLst, coords=Coords)

par(def.par)  # reset to default

denis-chabot/fishMO2 documentation built on July 16, 2020, 1:53 a.m.