[R] PCA legend outside of PCA plot

David L Carlson dcarlson at tamu.edu
Sun Sep 9 20:55:05 CEST 2012


Try adding the parameter xpd=TRUE to your legend() statement. Without
reproducible code it is pretty hard to be sure what the problem is.

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352



> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Tinus Sonnekus
> Sent: Sunday, September 09, 2012 1:37 PM
> To: r-help at r-project.org
> Subject: [R] PCA legend outside of PCA plot
> 
> Hi All,
> 
> I have been trying to get to plot my PCA legend outside of the PCA
> plot,
> but success still alludes me.
> 
> Can you guys please advise how I can achieve this. I used locater() to
> obtain coordinates for below the Comp.1 axis. Using these coordinates
> the
> legend disappears.
> 
> Below is the code for the PCA and legend.
> 
> Thanks in advance for the help.
> 
> Regards
> Tinus
> 
> 
> r.cols <- rainbow(length(unique(SEData$Seamount)))
> pca1 <- princomp(SEData3, scores=TRUE, cor=TRUE)
> biplot(pca1, var.axes= TRUE,
> xlabs=rep("",nrow(SEData3)),main="Seamounts
> PCA")
> rrr <- apply(pca1$scores[,1:2],2, range)
> par(usr=as.vector(rrr))
> points(pca1$scores[,1:2], col=r.cols , pch=20)
> legend(-8, 2.95, sm, col = r.cols, text.col = "black", lty = NULL,
> pch = 20,horiz = F,)
> 
> 
> --
> M.J. Sonnekus
> PhD Candidate (The Phytoplankton of the southern Agulhas Current Large
> Marine Ecosystem (ACLME))
> Department of Botany
> South Campus
> Nelson Mandela Metropolitan University
> PO Box 77000
> Port Elizabeth
> South Africa
> 6031
> 
> Cell: 082 080 9638
> E-mail: tsonnekus at gmail.com
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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