[R] Creating "Envelope" around a plot
WRAY NICHOLAS
nicholas.wray at ntlworld.com
Mon Nov 2 15:37:22 CET 2015
Hi Dennis thanks, but I'd already tried something like this -- the dashed lines
are parallel to the original plot vector, and not at a fixed maximal distance to
the original vector, where for example they would have curves around the peaks.
The boundary line points would only be parallel to the original vector line if
there is a straight stretch longer than 1 unit (if that is the minimal distance)
As I say it's the kind of thing one does at school using compass and ruler but
writing an R routine to do it is tricky and several times in the past I have
re-invented the R wheel, writing code for whose purpose it then turns out there
already is a R function, so I'd thought I'd ask...
But thanks for your time Nick
>
> On 02 November 2015 at 14:22 Dennis Murphy <djmuser at gmail.com> wrote:
>
>
> Hi:
>
> To produce the boundary lines one unit apart, this ought to work:
>
> veca<-c(4,3,6,5,7,3,2,3,3,6,8,7)
> plot(veca,type="l",lwd=2)
> lines(veca + 1, type = "l", lty = "dashed")
> lines(veca - 1, type = "l", lty = "dashed")
>
> If this is what you want, I suggest that you consult ?polygon to draw
> a shaded region between the boundary lines. I'll leave that as
> homework for you - see the examples section to see how to close the
> polygon.
>
> Dennis
>
> On Mon, Nov 2, 2015 at 4:33 AM, WRAY NICHOLAS
> <nicholas.wray at ntlworld.com> wrote:
> > Hi I am plotting various strands of information, and I want to create an
> > "envelope" around each line, so that the locus of the envelope is the
> > boundary
> > points no more than a fixed maximum distance from the plotted line, a
> > bit like
> > drawing a larger rectangle with paralle sides and curved compass corners
> > around
> > a smaller rectangle. Obviously I can work out how to do this in code
> > (eventually) but I suspect it would take me a while and i was wondering
> > whether
> > there was some R function which I don't know about which creates sets of
> > of
> > points at a given maximal distance
> >
> > the lines are simple vectors, ie like this noddy example
> >
> > veca<-c(4,3,6,5,7,3,2,3,3,6,8,7)
> > plot(veca,type="l",lwd=2)
> >
> > then I want to plot the locus of the boundary of all points no more than
> > (say) 1
> > unit from the line I imagine that one would have to provide a larger set
> > of
> > interpolated points between the actual points of veca, but I can do that
> > no
> > problem
> >
> > I'd be grateful if anyone out there in the R-ethervoid has any ideas
> >
> > Thanks, Nick Wray
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list