# Re: Plot where points are treatment letter Classic List Threaded 2 messages Reply | Threaded
Open this post in threaded view
|

## Re: Plot where points are treatment letter

 Here's an example: x = c(1,2,3,4,5); y = rnorm(5); labels = LETTERS[1:5]; plot(x,y, type = "n") # This sets up the plot but doesn't actually plot the points text(x,y, labels) # This adds labels to positions (x,y) HTH, Peter On Tue, Feb 8, 2011 at 12:42 PM, Schatzi <[hidden email]> wrote: > > I would like to create a plot of y vs x with different treatments where the > points are actually the letter of the treatment. Here is the code: > > A<-as.matrix(rnorm(10,10)) > B<-as.matrix(rnorm(10,9.5)) > C<-as.matrix(rnorm(10,10.5)) > Y<-as.matrix(rnorm(30,13)) > X<-rbind(A,B,C) > nA<-matrix("A",10,1) > nB<-matrix("B",10,1) > nC<-matrix("C",10,1) > TRT<-rbind(nA,nB,nC) > > plot(X,Y) > xyplot(Y~X,groups = TRT) > > The last plot colors the points by treatment, but it uses points, not the > letter for each treatment. Does anyone know how to do this? It seems simple > enough and I'm sure it is very easy, I just cannot figure it out nor have I > found the code. Thank you. > > > -- > View this message in context: http://r.789695.n4.nabble.com/Plot-where-points-are-treatment-letter-tp3276751p3276751.html> Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [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-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

## Re: Plot where points are treatment letter

 On Feb 8, 2011, at 3:42 PM, Schatzi wrote: > > I would like to create a plot of y vs x with different treatments   > where the > points are actually the letter of the treatment. Here is the code: > > A<-as.matrix(rnorm(10,10)) > B<-as.matrix(rnorm(10,9.5)) > C<-as.matrix(rnorm(10,10.5)) > Y<-as.matrix(rnorm(30,13)) > X<-rbind(A,B,C) > nA<-matrix("A",10,1) > nB<-matrix("B",10,1) > nC<-matrix("C",10,1) > TRT<-rbind(nA,nB,nC) > > plot(X,Y) > xyplot(Y~X,groups = TRT) ?plot ?xyplot  > plot(X,Y, pch=LETTERS[1:3], col=1:3)  > xyplot(Y~X,groups = TRT, pch=LETTERS[1:3], col=1:3) > > The last plot colors the points by treatment, but it uses points,   > not the > letter for each treatment. Does anyone know how to do this? It seems   > simple > enough and I'm sure it is very easy, I just cannot figure it out nor   > have I > found the code. Thank you. > > > -- > View this message in context: http://r.789695.n4.nabble.com/Plot-where-points-are-treatment-letter-tp3276751p3276751.html> Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [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. David Winsemius, MD West Hartford, CT ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.