Dear UseRs, A point was plotted by the following command plot(2,4,ylim=c(0,10),xlim=c(0,5)) how to divide the space around the plotted point into six regions each of 60 degree as shown in the Figure 2a) in the following link http://infolab.usc.edu/csci599/Fall2007/papers/b-2.pdf. Thankyou very much in advance, Eliza. [[alternative HTML version deleted]]
# A general approach to "lines" on a plot is provided by segments(). # However in this special case you can use abline(). # You have to take care though that your aspect ratio for the # plot is exactly 1. Therefore you have to set the asp parameter. p <- c(2,4) plot(p[1], p[2], xlim=c(0,5), ylim=c(0,10), xlab="", ylab="", asp=1.0) abline(h=p[2], lty=2) abline(p[2] - (p[1]*tan(pi/3)), tan(pi/3), lty=2) abline(p[2] + (p[1]*tan(pi/3)), -tan(pi/3), lty=2) # If you need to reproduce Fig. 2a more exactly: # - plot your frame a bit larger, don't draw axes # - draw the ablines # - draw two arrows to symbolize the coordinate axes p <- c(2,4) plot(p[1], p[2], xlim=c(-0.5,10.5), ylim=c(-0.5,10.5), , xlab="", ylab="", axes=n, asp=1.0) abline(h=p[2], lty=2) abline(p[2] - (p[1]*tan(pi/3)), tan(pi/3), lty=2) abline(p[2] + (p[1]*tan(pi/3)), -tan(pi/3), lty=2) arrows(0, 0, 10, 0, length=0.1) arrows(0, 0, 0, 10, length=0.1) Cheers, B. On Dec 21, 2014, at 2:25 PM, eliza botto <eliza_botto at hotmail.com> wrote:> Dear UseRs, > A point was plotted by the following command > plot(2,4,ylim=c(0,10),xlim=c(0,5)) > how to divide the space around the plotted point into six regions each of 60 degree as shown in the Figure 2a) in the following link http://infolab.usc.edu/csci599/Fall2007/papers/b-2.pdf. > Thankyou very much in advance, > Eliza. > > > > > [[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.
You may try this: > get.coords.circle <- function(x0, y0, r, len, rot){ + by <- seq(from=-pi, to=pi, length.out=len) + x <- r*cos(by+rot) + x0 + y <- r*sin(by+rot) + y0 + coords <- cbind(x,y) + coords[!duplicated(coords),] + } > xtms <- get.coords.circle(x0=2, y0=4, r=2, len=7, rot=0) > xtms1 <- get.coords.circle(x0=2, y0=4, r=1, len=7, rot=10) > > plot(xtms, type="n") > segments(x0=xtms[1:3,1], y0=xtms[1:3,2], + x=xtms[4:6,1], y=xtms[4:6,2]) > text(xtms[c(4,5,6),], labels=paste("line1", 1:3, sep="_")) > text(xtms1, labels=paste("S", 1:6, sep="_")) > points(x=2, y=4, cex=3) > Please see the output. Is this what you are looking for? I hope this helps. Chel Hee Lee On 12/21/2014 01:25 PM, eliza botto wrote:> Dear UseRs, > A point was plotted by the following command > plot(2,4,ylim=c(0,10),xlim=c(0,5)) > how to divide the space around the plotted point into six regions each of 60 degree as shown in the Figure 2a) in the following link http://infolab.usc.edu/csci599/Fall2007/papers/b-2.pdf. > Thankyou very much in advance, > Eliza. > > > > > [[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. >