[R] plot.stepfun xlim

m.u.r. mmuurr at gmail.com
Wed Dec 31 01:41:16 CET 2008

i've noticed a strange problem when plotting a stepfun.

according to the documentation, the xlim parameter should bound the
range of the function being plotted, and is returned as the extreme
two values (i.e. first and last) in the vector t from the plot.stepfun
call.  instead, it plots beyond the desired range (although the limits
are preserved for the viewing space).

to reproduce:

foo <- stepfun(0.5, c(1, 0));
bar <- plot(foo, xlim = c(0, 1));

now look at the plot, notice how the function extends beyond the
desired range.  also look at bar, which contains the vector t showing
the actual bounds (-1, 2) chosen by the function:

[1] -1.0 0.5 2.0

does anyone have an idea for me to limit the plotted function to the
specified extreme values (in this example c(0, 1))?

More information about the R-help mailing list