I think there may 3 legends should be added in your plot
the argument col, pch and pt.cex should be in the same length with legend,
but the objects col, pch
 and cex you defined former have 16*3 length. I guess the follow codes may
work

col <- rep(c("blue", "red", "darkgreen"), c(16, 16, 16)) 
## Choose different size of points 
cex <- rep(c(1, 1.2, 1), c(16, 16, 16)) 
## Choose the form of the points (square, circle, triangle and 
diamond-shaped 
pch <- rep(c(15, 16, 17), c(16, 16, 16)) 

plot(axis1, axis2, main="My plot", xlab="Axis 1", ylab="Axis 2", 
 col=c(Category, col), pch=pch, cex=cex) 
legend(4, 12.5, c("NorthAmerica", "SouthAmerica", "Asia"), col =
unique(col), 
       pch = unique(pch), pt.cex = unique(cex), title = "Region") 

--
View this message in context: 
http://r.789695.n4.nabble.com/Legend-based-on-levels-of-a-variable-tp4536796p4536868.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

Reply via email to