oce.plot.ts | R Documentation |
Plot a time-series, obeying the timezone and possibly drawing the range in the top-left margin.
oce.plot.ts(
x,
y,
type = "l",
xlim,
ylim,
log = "",
logStyle = "r",
flipy = FALSE,
xlab,
ylab,
drawTimeRange,
simplify = 2560,
fill = FALSE,
col = par("col"),
pch = par("pch"),
cex = par("cex"),
cex.axis = par("cex.axis"),
cex.lab = par("cex.lab"),
cex.main = par("cex.main"),
xaxs = par("xaxs"),
yaxs = par("yaxs"),
mgp = getOption("oceMgp"),
mar = c(mgp[1] + if (nchar(xlab) > 0) 1.5 else 1, mgp[1] + 1.5, mgp[2] + 1, mgp[2] +
3/4),
main = "",
despike = FALSE,
axes = TRUE,
tformat,
marginsAsImage = FALSE,
grid = FALSE,
grid.col = "lightgray",
grid.lty = "dotted",
grid.lwd = par("lwd"),
debug = getOption("oceDebug"),
...
)
x |
the times of observations. If this is not a POSIXt object, then an
attempt is made to convert it to one using |
y |
the observations. |
type |
plot type, |
xlim |
optional limit for x axis. This has an additional effect, beyond that for conventional R functions: it effectively windows the data, so that autoscaling will yield limits for y that make sense within the window. |
ylim |
optional limit for y axis. |
log |
a character value that must be either empty (the default) for linear
|
logStyle |
a character value that indicates how to draw the y axis, if
|
flipy |
Logical, with |
xlab |
name for x axis; defaults to |
ylab |
name for y axis; defaults to the plotted item. |
drawTimeRange |
an optional indication of whether/how to draw a time range,
in the top-left margin of the plot; see |
simplify |
an integer value that indicates
whether to speed up |
fill |
boolean, set |
col |
The colours for points (if |
pch |
character code, used if |
cex |
numeric character expansion factor for points on plots, ignored unless
|
cex.axis , cex.lab , cex.main |
numeric character expansion factors for axis numbers,
axis names and plot titles; see |
xaxs |
control x axis ending; see |
yaxs |
control y axis ending; see |
mgp |
3-element numerical vector to use for |
mar |
value to be used with |
main |
title of plot. |
despike |
boolean flag that can turn on despiking with
|
axes |
boolean, set to |
tformat |
optional format for labels on the time axis |
marginsAsImage |
boolean indicating whether to set the right-hand
margin to the width normally taken by an image drawn with
|
grid |
if |
grid.col |
color of grid |
grid.lty |
line type of grid |
grid.lwd |
line width of grid |
debug |
a flag that turns on debugging. Set to 1 to get a moderate amount of debugging information, or to 2 to get more. |
... |
graphical parameters passed down to |
Depending on the version of R, the standard plot()
and
plot.ts()
routines will not obey the time zone of the data.
This routine gets around that problem. It can also plot the time range in
the top-left margin, if desired; this string includes the timezone, to
remove any possible confusion.
The time axis is drawn with oce.axis.POSIXct()
.
A list is silently returned, containing xat
and yat
,
values that can be used by oce.grid()
to add a grid to the plot.
Dan Kelley and Clark Richards
library(oce)
t0 <- as.POSIXct("2008-01-01", tz = "UTC")
t <- seq(t0, length.out = 48, by = "30 min")
y <- sin(as.numeric(t - t0) * 2 * pi / (12 * 3600))
oce.plot.ts(t, y, type = "l", xaxs = "i")
# Show how col, pch and cex get recycled
oce.plot.ts(t, y,
type = "p", xaxs = "i",
col = 1:3, pch = c(rep(1, 6), rep(20, 6)), cex = sqrt(1:6)
)
# Trimming x; note the narrowing of the y view
oce.plot.ts(t, y, type = "p", xlim = c(t[6], t[12]))
# Flip the y axis
oce.plot.ts(t, y, flipy = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.