Hi, I have a matrix: [,1] [,2] [1,] 11 31 [2,] 44 50 [3,] 23 100 [4,] 90 31 I use plot to draw the four points. Is there any way to label the point? for insatnce, for (11,31), it is "1", for (44,50), it is "4". Thanks! --------------------------------- [[alternative HTML version deleted]]
Hallo On 28 Nov 2005 at 21:33, Robert wrote: Date sent: Mon, 28 Nov 2005 21:33:24 -0800 (PST) From: Robert <samrobertsmith at yahoo.com> To: r-help at stat.math.ethz.ch Subject: [R] label point> Hi, I have a matrix: > [,1] [,2] > [1,] 11 31 > [2,] 44 50 > [3,] 23 100 > [4,] 90 31 > I use plot to draw the four points. Is there any way to label the > point? for insatnce, for (11,31), it is "1", for (44,50), it is "4". > Thanks! >label.vec<-c(1, 4, l2, l3.....) plot(matrix) text(matrix, label.vec) Should do the trick but it overplots your points, so you need to shift positions e.g. by text(matrix+c(some offset,0), label.vec) HTH Petr> > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlPetr Pikal petr.pikal at precheza.cz
See ?text e.g. plot(m[,1], m[,2]) # or plot(m) text(m[,1], m[,2], pos = 3, cex = 0.7) # 3 means above, 0.7 is 70% size On 11/29/05, Robert <samrobertsmith at yahoo.com> wrote:> Hi, I have a matrix: > [,1] [,2] > [1,] 11 31 > [2,] 44 50 > [3,] 23 100 > [4,] 90 31 > I use plot to draw the four points. Is there any way to label the point? for insatnce, for (11,31), it is "1", for (44,50), it is "4". > Thanks! > > > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
You could also use plot(matrix,type="n") to avoid overplot. -----Original Message----- From: Petr Pikal [mailto:petr.pikal at precheza.cz] Sent: November 29, 2005 3:05 AM To: Robert; r-help at stat.math.ethz.ch Subject: Re: [R] label point Hallo On 28 Nov 2005 at 21:33, Robert wrote: Date sent: Mon, 28 Nov 2005 21:33:24 -0800 (PST) From: Robert <samrobertsmith at yahoo.com> To: r-help at stat.math.ethz.ch Subject: [R] label point> Hi, I have a matrix: > [,1] [,2] > [1,] 11 31 > [2,] 44 50 > [3,] 23 100 > [4,] 90 31 > I use plot to draw the four points. Is there any way to label the > point? for insatnce, for (11,31), it is "1", for (44,50), it is "4". > Thanks! >label.vec<-c(1, 4, l2, l3.....) plot(matrix) text(matrix, label.vec) Should do the trick but it overplots your points, so you need to shift positions e.g. by text(matrix+c(some offset,0), label.vec) HTH Petr> > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlPetr Pikal petr.pikal at precheza.cz ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html