[R] plot.stepfun xlim
mmuurr at gmail.com
Wed Dec 31 17:54:36 CET 2008
I suppose to be more clear, what I mean is that I was hoping to find
upper/lower bounding parameter/rule, similar to "rule = 1" in the
approxfun command (which returns NA for any specified x-value outside
the defined domain). Actually, that's exactly what I would like: a
stepfun function that has a bounded domain.
And reading the phrase, "range of 'x' values to use" indicated just
this. I'm now aware that it gets forwarded on to the plot command,
but that doesn't solve the problem of the points being chosen for the
lines in the plot extending beyond the desired range.
Instead I'm now simply working with approxfun, but this is something
of a compromise as now plotting involves a series of extra commands to
draw the step function (in particular I was drawing the function with
'verticals = FALSE' so now I've written a separate function to draw
the approxfun within the bounds of the function using a series of line
segments... although this is something of a pain in the arse).
Alternatively I can stick with the stepfun and either hack up the
display (i.e. play with the axes and margins), or hack up the stepfun
itself (add two more plateaus, one on each side of my "domain", with
values that are beyond the range that I ever intend on displaying in
the figure). All of these possibilities aren't exactly elegant,
On Dec 31, 11:35 am, "Stavros Macrakis" <macra... at alum.mit.edu> wrote:
> > On Tue, 30 Dec 2008, m.u.r. wrote:
> >> according to the documentation, the xlim parameter should bound the
> >> range of the function being plotted, and is returned as the extreme
> On Wed, Dec 31, 2008 at 4:18 AM, Prof Brian Ripley
> <rip... at stats.ox.ac.uk> replied:
> > Wheere does it say that?
> True, it doesn't say that. As you say, ?plot.stepfun says
> > xlim,ylim: numeric(2) each; range of 'x' or 'y' values to use....
> and ?plot.window says
> xlim, ylim: numeric vectors of length 2, giving the x and y
> coordinates [sic] ranges.
> ...both of which are rather vague, not saying what the *effect* of
> these "ranges" is. Perhaps a more precise description would be:
> xlim, ylim: each is numeric(2) and defines the range of the x and
> y scales. cf. xaxs; xpd.
> More experienced users can perhaps come up with better language.
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help