data(Hitters)
attach(Hitters)
colors <- c("black","red","green","blue","red","black","blue")
pch <- substr(levels(Positions), 1, 1)
ternaryplot(
Hitters[,2:4],
pch = as.character(Positions),
col = colors[as.numeric(Positions)],
main = "Baseball Hitters Data"
)
legend(
0.7, 0.85,
legend = c("POSITION(S)", levels(Positions)),
pch = c("", pch),
col = c(NA, colors)
)
detach(Hitters)
Run the code above in your browser using DataLab