| Line 10... |
Line 10... |
| 10 |
\description{
|
10 |
\description{
|
| 11 |
Method of the generic \code{\link{plot}} for \code{\link{stepfun}}
|
11 |
Method of the generic \code{\link{plot}} for \code{\link{stepfun}}
|
| 12 |
objects and utility for plotting piecewise constant functions.
|
12 |
objects and utility for plotting piecewise constant functions.
|
| 13 |
}
|
13 |
}
|
| 14 |
\usage{
|
14 |
\usage{
|
| 15 |
\method{plot}{stepfun}(x, xval, xlim, ylim = range(c(y,Fn.kn)),
|
15 |
\method{plot}{stepfun}(x, xval, xlim, ylim = range(c(y, Fn.kn)),
|
| 16 |
xlab = "x", ylab = "f(x)", main = NULL,
|
16 |
xlab = "x", ylab = "f(x)", main = NULL,
|
| 17 |
add = FALSE, verticals = TRUE, do.points = (n < 1000),
|
17 |
add = FALSE, verticals = TRUE, do.points = (n < 1000),
|
| 18 |
pch = par("pch"), col = par("col"),
|
18 |
pch = par("pch"), col = par("col"),
|
| 19 |
col.points = col, cex.points = par("cex"),
|
19 |
col.points = col, cex.points = par("cex"),
|
| 20 |
col.hor = col, col.vert = col,
|
20 |
col.hor = col, col.vert = col,
|
| Line 63... |
Line 63... |
| 63 |
y0 <- c(1,2,4,3)
|
63 |
y0 <- c(1,2,4,3)
|
| 64 |
sfun0 <- stepfun(1:3, y0, f = 0)
|
64 |
sfun0 <- stepfun(1:3, y0, f = 0)
|
| 65 |
sfun.2 <- stepfun(1:3, y0, f = .2)
|
65 |
sfun.2 <- stepfun(1:3, y0, f = .2)
|
| 66 |
sfun1 <- stepfun(1:3, y0, right = TRUE)
|
66 |
sfun1 <- stepfun(1:3, y0, right = TRUE)
|
| 67 |
|
67 |
|
| 68 |
tt <- seq(0,3, by = 0.1)
|
68 |
tt <- seq(0, 3, by = 0.1)
|
| 69 |
op <- par(mfrow = c(2,2))
|
69 |
op <- par(mfrow = c(2,2))
|
| 70 |
plot(sfun0); plot(sfun0, xval = tt, add = TRUE, col.hor = "bisque")
|
70 |
plot(sfun0); plot(sfun0, xval = tt, add = TRUE, col.hor = "bisque")
|
| 71 |
plot(sfun.2);plot(sfun.2, xval = tt, add = TRUE, col = "orange")# all colors
|
71 |
plot(sfun.2);plot(sfun.2, xval = tt, add = TRUE, col = "orange") # all colors
|
| 72 |
plot(sfun1);lines(sfun1, xval = tt, col.hor = "coral")
|
72 |
plot(sfun1);lines(sfun1, xval = tt, col.hor = "coral")
|
| 73 |
##-- This is revealing :
|
73 |
##-- This is revealing :
|
| 74 |
plot(sfun0, verticals = FALSE,
|
74 |
plot(sfun0, verticals = FALSE,
|
| 75 |
main = "stepfun(x, y0, f=f) for f = 0, .2, 1")
|
75 |
main = "stepfun(x, y0, f=f) for f = 0, .2, 1")
|
| 76 |
for(i in 1:3)
|
76 |
for(i in 1:3)
|
| 77 |
lines(list(sfun0, sfun.2, stepfun(1:3,y0,f = 1))[[i]], col = i)
|
77 |
lines(list(sfun0, sfun.2, stepfun(1:3, y0, f = 1))[[i]], col = i)
|
| 78 |
legend(2.5, 1.9, paste("f =", c(0,0.2,1)), col = 1:3, lty = 1, y.intersp = 1)
|
78 |
legend(2.5, 1.9, paste("f =", c(0, 0.2, 1)), col = 1:3, lty = 1, y.intersp = 1)
|
| 79 |
par(op)
|
79 |
par(op)
|
| 80 |
|
80 |
|
| 81 |
# Extend and/or restrict 'viewport':
|
81 |
# Extend and/or restrict 'viewport':
|
| 82 |
plot(sfun0, xlim = c(0,5), ylim = c(0, 3.5),
|
82 |
plot(sfun0, xlim = c(0,5), ylim = c(0, 3.5),
|
| 83 |
main = "plot(stepfun(*), xlim= . , ylim = .)")
|
83 |
main = "plot(stepfun(*), xlim= . , ylim = .)")
|