Dear All, I am trying to add some text annotation to a graph using matplot() as follows: vars <- c("v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v8", "v10") id <- seq(5.000, 0.001, by = -0.001) sid <- c(4.997, 3.901, 2.339, 0.176, 0.151, 0.101, 0.076, 0.051, 0.026, 0.001) rn <- sample(seq(0, 0.6, by = 0.001), 5000, replace = T) matplot(rbind(rn, rep(0, length(rn))), rbind(id, id), xlim = c(0, 1), type = "l", lty = 1, lwd = 1, col = 1, xlab = "", ylab = "", axes = F) abline(v = 0, lty = 2) axis(1) mtext(side = 2, text = c(vars), at = sid, las = 2, line = 0.8) axis(3) But the text annotation can not be displayed correctly, i.e., some of them stick together. Can anybody help me with this particular problem? Thanks in advance. Lisa -- View this message in context: http://r.789695.n4.nabble.com/Text-annotation-of-a-graph-tp3719775p3719775.html Sent from the R help mailing list archive at Nabble.com.
Hi Lisa, On 4.Aug.2011, at 22:24, Lisa wrote:> Dear All, > > I am trying to add some text annotation to a graph using matplot() as > follows: > > vars <- c("v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v8", "v10") > id <- seq(5.000, 0.001, by = -0.001) > sid <- c(4.997, 3.901, 2.339, 0.176, 0.151, 0.101, 0.076, 0.051, 0.026, > 0.001) > rn <- sample(seq(0, 0.6, by = 0.001), 5000, replace = T) > matplot(rbind(rn, rep(0, length(rn))), rbind(id, id), xlim = c(0, 1), > type = "l", lty = 1, lwd = 1, col = 1, xlab = "", > ylab = "", axes = F) > abline(v = 0, lty = 2) > axis(1) > mtext(side = 2, text = c(vars), at = sid, las = 2, line = 0.8) > axis(3) > > But the text annotation can not be displayed correctly, i.e., some of them > stick together.Looking at your code that is exactly what you asked for ....> Can anybody help me with this particular problem? Thanks in advance. >What exactly would you like to do? Benno
Thanks you for your reply. I consider only the performance of ?vars? (v1 to v10), so I just want to indicate then on the y-axis at the point they should be located. Lisa -- View this message in context: http://r.789695.n4.nabble.com/Text-annotation-of-a-graph-tp3719775p3721799.html Sent from the R help mailing list archive at Nabble.com.
Look at the spread.labs function in the TeachingDemos package, it may do what you want (see the examples). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Lisa > Sent: Friday, August 05, 2011 11:42 AM > To: r-help at r-project.org > Subject: Re: [R] Text annotation of a graph > > Thanks you for your reply. > > I consider only the performance of ?vars? (v1 to v10), so I just want > to > indicate then on the y-axis at the point they should be located. > > Lisa > > > -- > View this message in context: http://r.789695.n4.nabble.com/Text- > annotation-of-a-graph-tp3719775p3721799.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.