[R] stricter use of xlim in plot.stepfun
jim at bitwrit.com.au
Tue May 26 13:37:32 CEST 2009
Sebastian Meyer wrote:
> 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.
Have a look at par(xaxs="i"), which you can pass to the plot function as
More information about the R-help