[R] How to change the ylim in plot.stepfun function

Uwe Ligges ligges at statistik.uni-dortmund.de
Sat Nov 2 17:32:11 CET 2002


Shawn Lee wrote:
> 
> dear R-Guru,
> 
> Anybody knows how to change the range of Y axis in plot.stepfun.
> I want to overlap several stepping data with different y ranges.  But can't make it
> becaues there is no option for ylim.

Right. But it's easy to add that option. Just change the following lines
in the function definition:


plot.stepfun <-
-   function(x, xval, xlim, xlab = "x", ylab = "f(x)", main = NULL,
+   function(x, xval, xlim, ylim, xlab = "x", ylab = "f(x)", main =
NULL,
             add = FALSE, verticals = TRUE, do.points = TRUE,

...

    else {
+   if(missing(ylim)) ylim <- range(c(y,Fn.kn))
-   plot(0,0, type="n", xlim=xlim, ylim=range(c(y,Fn.kn)),
+   plot(0,0, type="n", xlim=xlim, ylim=ylim,
         xlab=xlab, ylab=ylab, main= main, ...)
    segments(ti.l, y, ti.r, y, col=col.hor, lty=lty, lwd=lwd)
    }


Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list