Re: [R] Vegan plotting- color help

From: hadley wickham <h.wickham_at_gmail.com>
Date: Fri, 11 Apr 2008 12:09:34 -0500

> ## 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/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 11 Apr 2008 - 17:11:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Apr 2008 - 17:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive