Skip to content

How to change the ylim in plot.stepfun function

2 messages · Shawn Lee, Uwe Ligges

#
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.

Thanks in advance.

Shawn Lee
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Shawn.Lee.vcf
Type: text/x-vcard
Size: 333 bytes
Desc: Card for Shawn Lee
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20021101/c850d109/Shawn.Lee.vcf
1 day later
#
Shawn Lee wrote:
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._