One of the domain where ggplot2
excels , comparing to other R system plots, is mapping plot parameters to data variables.( via aesthetics mechanism)
library(ggplot2)
dat <- data.frame(X =runif(20),
Y =runif(20),
att1 = gl(5,20/5),
att2 =gl(3,20/3))
ggplot(dat,aes(x=X,y=Y,color=att1,shape=att2)) +
geom_point(size=5)
You can do it in the base plot also, but you should generate manually the legend ...
plot(dat$X,dat$Y,pch=as.integer(dat$att1),col=as.integer(dat$att1))