Hello all,
How to draw a line in plot when I know the start point(x1,y1) and end point(x2,y2)? I need make this as additional information in the graph: plot(wl2[[1]],wl2[[2]]) I think that is possible make this with the function abline(), is possible? I looked the function lines() too, but don't understand as make. Thanks! Lesandro Veja quais são os assuntos do momento no Yahoo! +Buscados [[alternative HTML version deleted]] ______________________________________________ [hidden email] 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. |
Dear Lesandro,
Take a look at ?segments HTH, Jorge On Thu, Jun 25, 2009 at 2:30 PM, Lesandro <[hidden email]> wrote: > Hello all, > > How to draw a line in plot when I know the start point(x1,y1) and end > point(x2,y2)? I need make this as additional information in the graph: > > plot(wl2[[1]],wl2[[2]]) > > I think that is possible make this with the function abline(), is possible? > I looked the function lines() too, but don't understand as make. > > > Thanks! > Lesandro > > > > Veja quais são os assuntos do momento no Yahoo! +Buscados > > [[alternative HTML version deleted]] > > > ______________________________________________ > [hidden email] 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. > > ______________________________________________ [hidden email] 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. |
In reply to this post by Lesandro
On Jun 25, 2009, at 1:30 PM, Lesandro wrote:
> Hello all, > > How to draw a line in plot when I know the start point(x1,y1) and > end point(x2,y2)? I need make this as additional information in the > graph: > > plot(wl2[[1]],wl2[[2]]) > > I think that is possible make this with the function abline(), is > possible? I looked the function lines() too, but don't understand as > make. > > > Thanks! > Lesandro See ?segments which does just what you are looking for. lines() is more designed for a series of connected lines (eg. a polygon) rather than a single line segment. abline() can draw a straight line, at a given vertical or horizontal position, or if given a linear model object, the fitted line. HTH, Marc Schwartz ______________________________________________ [hidden email] 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. |
On 25-Jun-09 18:38:37, Marc Schwartz wrote:
> On Jun 25, 2009, at 1:30 PM, Lesandro wrote: >> Hello all, >> How to draw a line in plot when I know the start point(x1,y1) >> and end point(x2,y2)? I need make this as additional information >> in the graph: >> >> plot(wl2[[1]],wl2[[2]]) >> >> I think that is possible make this with the function abline(), is >> possible? I looked the function lines() too, but don't understand >> as make. >> >> Thanks! >> Lesandro > > See ?segments which does just what you are looking for. > > lines() is more designed for a series of connected lines (eg. a > polygon) rather than a single line segment. > > abline() can draw a straight line, at a given vertical or horizontal > position, or if given a linear model object, the fitted line. > HTH, > Marc Schwartz Hmm ... for this particular purpose I don't see what is wrong with plot(wl2[[1]],wl2[[2]]) lines(c(x1,x2),c(y1,y2)) along with any additional paramaters to lines() for line-type, colour, etc. -- I do this all the time ... Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[hidden email]> Fax-to-email: +44 (0)870 094 0861 Date: 25-Jun-09 Time: 19:51:20 ------------------------------ XFMail ------------------------------ ______________________________________________ [hidden email] 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. |
On Jun 25, 2009, at 1:51 PM, Ted Harding wrote: > On 25-Jun-09 18:38:37, Marc Schwartz wrote: >> On Jun 25, 2009, at 1:30 PM, Lesandro wrote: >>> Hello all, >>> How to draw a line in plot when I know the start point(x1,y1) >>> and end point(x2,y2)? I need make this as additional information >>> in the graph: >>> >>> plot(wl2[[1]],wl2[[2]]) >>> >>> I think that is possible make this with the function abline(), is >>> possible? I looked the function lines() too, but don't understand >>> as make. >>> >>> Thanks! >>> Lesandro >> >> See ?segments which does just what you are looking for. >> >> lines() is more designed for a series of connected lines (eg. a >> polygon) rather than a single line segment. >> >> abline() can draw a straight line, at a given vertical or horizontal >> position, or if given a linear model object, the fitted line. >> HTH, >> Marc Schwartz > > Hmm ... for this particular purpose I don't see what is wrong with > > plot(wl2[[1]],wl2[[2]]) > lines(c(x1,x2),c(y1,y2)) > > along with any additional paramaters to lines() for line-type, > colour, etc. -- I do this all the time ... > Ted. Nothing wrong at all Ted. It will of course work. For example: plot(1:10) lines(c(2, 4), c(6, 8)) That will give you the same result as: plot(1:10) segments(2, 6, 4, 8) In this case, it may be a matter of choice. For single lines, I tend to use segments(). As is frequently the case with R, there is more than one way to skin the feline... Regards, Marc ______________________________________________ [hidden email] 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. |
Free forum by Nabble | Edit this page |