[R] Plot where points are treatment letter

Peter Langfelder peter.langfelder at gmail.com
Tue Feb 8 22:32:25 CET 2011


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 <adele_thompson at cargill.com> 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.
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list