[R] stricter use of xlim in plot.stepfun

Sebastian Meyer Sebastian.Wastl.Meyer at campus.lmu.de
Tue May 26 12:41:34 CEST 2009

Dear R developer,

I am not quite sure, if I should post my concern as a wish to
r-bugs at r-project.org. Thus, as recommended, I first send an email to you.

My request is the following: I would appreciate, if it was possible to
obtain a plot of a 'stepfun' with a strict interpretation of xlim.
What I mean:

sf <- stepfun(1:4, 1:5)
plot(sf, xlim=c(0,10))

does not bound the function to the horizontal area from 0 to 10, but
continues drawing outside this interval.
Another situation: I want to add a stepfun to an existing plot:

plot(c(0, 50), c(0, 10), type = "n")
lines(sf, xlim = c(0,10))

The left and right ends of the line drawing are chosen quite arbitrary
instead of using the exact xlim information.
In the code of plot.stepfun it is the variable 'dr' in conjuction with
ti <- c(xlim[1L] - dr, knF, xlim[2L] + dr)
which determine and alter the x-range of the stepfun internally.

What do you think of this issue?
Best regards,
    Sebastian Meyer

More information about the R-help mailing list