Skip to content
Prev 319525 / 398506 Next

plotting

It is easy to do in base graphics, but probably a bad idea just because it
is very hard to decode the symbol/color combinations. I added a crude
legend:

# Provide reproducible data
set.seed(42)
value <- round(rnorm(20), 2)
time <- round(runif(20)*10, 1)
group <- sample(1:4)
id <- sample(1:5)
dta <- data.frame(value, time, group, id)

# Plot and legend
plot(value~time, pch=id+20, col=group, bg=group, cex=1.25)
legend("bottomright", as.character(1:4), pch=16, 
  col=1:4, bty="n", inset=c(0, .045), title="Group")
legend("bottomright", as.character(1:5), pch=21:25, col="gray", 
  inset=c(.1, 0), bty="n", title="ID")

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