[R] Vegan plotting- color help
hadley wickham
h.wickham at gmail.com
Fri Apr 11 19:09:34 CEST 2008
> ## dummy group ID
> group <- sample(rep(1:3, each = 4))
> ## create dummy grouping factor
> group <- factor(group, labels = paste("group", 1:3))
> group
>
> # vector of colours
> cols <- c("red", "blue", "green")
> ## dummay data to plot
> datx <- runif(12)
> daty <- runif(12)
>
> ## plot it
> plot(datx, daty, col = cols[group], pch = 16)
Or even more easily with ggplot2:
install.packages("ggplot2")
library(ggplot2)
qplot(datx, daty, colour = group)
which also takes care of adding the legend.
Hadley
--
http://had.co.nz/
More information about the R-help
mailing list