Description Usage Arguments Details Value Author(s) See Also Examples
Draw a sequence of points, lines, or box-and-whiskers.
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 | PlotGraph(
x,
y,
xlab,
ylab,
main = NULL,
asp = NA,
xlim = NULL,
ylim = NULL,
xn = 5,
yn = 5,
ylog = FALSE,
type = "s",
lty = 1,
lwd = 0.7,
pch = NULL,
col = NULL,
bg = NA,
fill = "none",
fillcolor = NULL,
pt.cex = 1,
xpd = FALSE,
seq.date.by = NULL,
scientific = NA,
conversion.factor = NULL,
boxwex = 0.8,
center.date.labels = FALSE,
bg.polygon = NULL,
add.grid = TRUE
)
|
x, y |
'Date' vector, 'numeric' vector, 'matrix', or 'data.frame'.
Data for plotting where the vector length or number of rows should match.
If |
xlab |
'character' string. Title for x axis. |
ylab |
'character' vector of length 2.
Title for the 1st and 2nd-y axes.
The title for the 2nd-y axis is optional and requires |
main |
'character' string. Main title for the plot. |
asp |
'numeric' number.
y/x aspect ratio for spatial axes.
Defaults to 1 (one unit on the x-axis equals one unit on the y-axis) when |
xlim |
'numeric' or 'Date' vector of length 2. Minimum and maximum values for the x-axis. |
ylim |
'numeric' vector of length 2. Minimum and maximum values for the y-axis. |
xn, yn |
'integer' count. Desired number of intervals between tick-marks on the x- and y-axis, respectively. |
ylog |
'logical' flag. Whether a logarithm scale is used for the y axis. |
type |
'character' string. Plot type, possible types are
|
lty |
'integer' vector.
Line type, see |
lwd |
'numeric' number. Line width |
pch |
'integer' count.
Point type, see |
col |
'character' vector or 'function'.
Point or line color, see |
bg |
'character' vector.
Background colors for the open plot symbols given by |
fill |
'character' string.
Used to create filled area plots. Specify
|
fillcolor |
'character' vector.
Colors for basic filled area plots.
Defaults to a half-transparent variant of the line color ( |
pt.cex |
'numeric' number. Expansion factor for the point symbols. |
xpd |
'logical' flag. Whether to prevent point and (or) line symbols from being clipped to the plot region. |
seq.date.by |
'character' string, 'numeric' number, or 'difftime'.
The increment of the date sequence, see the |
scientific |
'logical' vector of length 1, 2, or 3, value is recycled as necessary.
Whether axes labels should be encoded in nice scientific format.
Vector elements correspond to the x-axis, |
conversion.factor |
'numeric' number. Conversion factor for the 2nd-y axis. |
boxwex |
'numeric' number. Scale factor to be applied to all boxes, only applicable for box-and-whisker plots. |
center.date.labels |
'logical' flag. If true, date labels are horizontally centered between x-axis tickmarks. |
bg.polygon |
'list'.
If specified, a background polygon is drawn.
The polygon is described using a list of arguments supplied to the |
add.grid |
'logical' flag. Whether to draw a rectangular grid. |
Interval censored data (type = "i"
) requires y
be matrix of 2 columns.
The first column contains the starting values, the second the ending values.
Observations are represented using
(y0, Inf)
for right-censored value,
(y0, y0)
for exact value, and
(-Inf, y1)
for left-censored value, and
(y0, y1)
for an interval censored value.
Where infinity is represented as Inf
or NA
, and y
is a numeric value.
Invisible NULL
J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center
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 | n <- 50L
x <- as.Date("2008-07-12") + 1:n
y <- sample.int(n, replace = TRUE)
PlotGraph(x, y, ylab = paste("Random number in", c("meters", "feet")),
main = "Main Title", type = "p", pch = 16,
scientific = FALSE, conversion.factor = 3.28)
y <- data.frame(lapply(1:3, function(i) sample(n, replace = TRUE)),
stringsAsFactors = TRUE)
PlotGraph(x, y, ylab = "Random number", pch = 1,
seq.date.by = "days", scientific = TRUE)
y <- sapply(1:3, function(i) {
sample((1:100) + i * 100, n, replace = TRUE)
})
m <- cbind(as.numeric(x), y)
col <- GetColors(3, scheme = "bright")
PlotGraph(m, xlab = "Number", ylab = "Random number", type = "b",
pch = 15:17, col = col, pt.cex = 0.9)
legend("topright", LETTERS[1:3], inset = 0.02, col = col, lty = 1,
pch = 15:17, pt.cex = 0.9, cex = 0.7, bg = "white")
d <- data.frame(x = as.Date("2008-07-12") + 1:8 * 1000,
y0 = c(NA, NA, 1, 3, 1, 4, 2, pi),
y1 = c(1, 2, NA, NA, 4, 3, 2, pi),
stringsAsFactors = TRUE)
PlotGraph(d, type = "i", ylim = c(0, 5), xpd = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.