Skip to content
Prev 168913 / 398506 Next

Defining plot colors based on a variable

On Mon, Feb 2, 2009 at 8:56 AM, Andrew Singleton <singleta at mail.nih.gov> wrote:
You might find it easier to use ggplot2:

install.packages("ggplot2")
library(ggplot2)

qplot(BP, P, data = curr_assoc, colour = FILE, log="y")

To ensure that you always have the same colours, you can set the
limits for the colour scale (in analogous way to setting the limits
for the x axis):

qplot(BP, P, data = curr_assoc, colour = FILE, log="y") +
scale_colour_hue(limits = c(2, 7, 12, 34, 60, 64, 65, 70, 71))

Hadley