EVOLUTION-MANAGER
Edit File: plot.stepfun.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Plot Step Functions</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for plot.stepfun {stats}"><tr><td>plot.stepfun {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Plot Step Functions</h2> <h3>Description</h3> <p>Method of the generic <code><a href="../../graphics/html/plot.html">plot</a></code> for <code><a href="stepfun.html">stepfun</a></code> objects and utility for plotting piecewise constant functions. </p> <h3>Usage</h3> <pre> ## S3 method for class 'stepfun' plot(x, xval, xlim, ylim = range(c(y, Fn.kn)), xlab = "x", ylab = "f(x)", main = NULL, add = FALSE, verticals = TRUE, do.points = (n < 1000), pch = par("pch"), col = par("col"), col.points = col, cex.points = par("cex"), col.hor = col, col.vert = col, lty = par("lty"), lwd = par("lwd"), ...) ## S3 method for class 'stepfun' lines(x, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>an <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> object inheriting from <code>"stepfun"</code>.</p> </td></tr> <tr valign="top"><td><code>xval</code></td> <td> <p>numeric vector of abscissa values at which to evaluate <code>x</code>. Defaults to <code><a href="stepfun.html">knots</a>(x)</code> restricted to <code>xlim</code>.</p> </td></tr> <tr valign="top"><td><code>xlim, ylim</code></td> <td> <p>limits for the plot region: see <code><a href="../../graphics/html/plot.window.html">plot.window</a></code>. Both have sensible defaults if omitted.</p> </td></tr> <tr valign="top"><td><code>xlab, ylab</code></td> <td> <p>labels for x and y axis.</p> </td></tr> <tr valign="top"><td><code>main</code></td> <td> <p>main title.</p> </td></tr> <tr valign="top"><td><code>add</code></td> <td> <p>logical; if <code>TRUE</code> only <em>add</em> to an existing plot.</p> </td></tr> <tr valign="top"><td><code>verticals</code></td> <td> <p>logical; if <code>TRUE</code>, draw vertical lines at steps.</p> </td></tr> <tr valign="top"><td><code>do.points</code></td> <td> <p>logical; if <code>TRUE</code>, also draw points at the (<code>xlim</code> restricted) knot locations. Default is true, for sample size <i>< 1000</i>.</p> </td></tr></table> <table summary="R argblock"> <tr valign="top"><td><code>pch</code></td> <td> <p>character; point character if <code>do.points</code>.</p> </td></tr> <tr valign="top"><td><code>col</code></td> <td> <p>default color of all points and lines.</p> </td></tr> <tr valign="top"><td><code>col.points</code></td> <td> <p>character or integer code; color of points if <code>do.points</code>.</p> </td></tr> <tr valign="top"><td><code>cex.points</code></td> <td> <p>numeric; character expansion factor if <code>do.points</code>.</p> </td></tr> <tr valign="top"><td><code>col.hor</code></td> <td> <p>color of horizontal lines.</p> </td></tr> <tr valign="top"><td><code>col.vert</code></td> <td> <p>color of vertical lines.</p> </td></tr> <tr valign="top"><td><code>lty, lwd</code></td> <td> <p>line type and thickness for all lines.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments of <code><a href="../../graphics/html/plot.html">plot</a>(.)</code>, or if<code>(add)</code> <code><a href="../../graphics/html/segments.html">segments</a>(.)</code>.</p> </td></tr> </table> <h3>Value</h3> <p>A list with two components </p> <table summary="R valueblock"> <tr valign="top"><td><code>t</code></td> <td> <p>abscissa (x) values, including the two outermost ones.</p> </td></tr> <tr valign="top"><td><code>y</code></td> <td> <p>y values ‘in between’ the <code>t[]</code>.</p> </td></tr> </table> <h3>Author(s)</h3> <p>Martin Maechler <a href="mailto:maechler@stat.math.ethz.ch">maechler@stat.math.ethz.ch</a>, 1990, 1993; ported to <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>, 1997.</p> <h3>See Also</h3> <p><code><a href="ecdf.html">ecdf</a></code> for empirical distribution functions as special step functions, <code><a href="approxfun.html">approxfun</a></code> and <code><a href="splinefun.html">splinefun</a></code>. </p> <h3>Examples</h3> <pre> require(graphics) y0 <- c(1,2,4,3) sfun0 <- stepfun(1:3, y0, f = 0) sfun.2 <- stepfun(1:3, y0, f = .2) sfun1 <- stepfun(1:3, y0, right = TRUE) tt <- seq(0, 3, by = 0.1) op <- par(mfrow = c(2,2)) plot(sfun0); plot(sfun0, xval = tt, add = TRUE, col.hor = "bisque") plot(sfun.2);plot(sfun.2, xval = tt, add = TRUE, col = "orange") # all colors plot(sfun1);lines(sfun1, xval = tt, col.hor = "coral") ##-- This is revealing : plot(sfun0, verticals = FALSE, main = "stepfun(x, y0, f=f) for f = 0, .2, 1") for(i in 1:3) lines(list(sfun0, sfun.2, stepfun(1:3, y0, f = 1))[[i]], col = i) legend(2.5, 1.9, paste("f =", c(0, 0.2, 1)), col = 1:3, lty = 1, y.intersp = 1) par(op) # Extend and/or restrict 'viewport': plot(sfun0, xlim = c(0,5), ylim = c(0, 3.5), main = "plot(stepfun(*), xlim= . , ylim = .)") ##-- this works too (automatic call to ecdf(.)): plot.stepfun(rt(50, df = 3), col.vert = "gray20") </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>