[R] plot.stepfun xlim

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Dec 31 10:18:27 CET 2008


On Tue, 30 Dec 2008, m.u.r. wrote:

> 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

Wheere does it say that?  The help actually says

xlim,ylim: numeric(2) each; range of 'x' or 'y' values to use.  Both
           have sensible defaults.

They are just passed on to plot.window.  You may be looking for par 
'xaxs' (and 'xpd').

> 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));

Why are you adding two blank commands via the semicolons?

> 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:
>
> $t
> [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))?
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list