This is not too complicated with lattice , as its key = argument accepts an arbitrary number of columns to be included in the legend.
library(lattice) myPCH <- 15:17 Data <- rnorm(50) Index <- seq(length(Data)) xyplot(Data ~ Index, pch = myPCH, col=1:2, key = list(space = "right", adj=1, text = list(c("a", "b", "c"), cex=1.5), points = list(pch = myPCH), points = list(pch = myPCH,col=2)))
I donβt know how to include a legend in the plotting area, but with this kind of plot it seems better to have it outside. ( Edit: @chl in the comments indicates several ways to do this. For example, to draw a key in the lower left corner of the picture, replace space = "right" in the above corner = c(0,0) or x = 0, y=0.2 )

source share