Skip to content
Back to formatted view

Raw Message

Message-ID: <2E9C414912813E4EB981326983E0A10403F40E45@inboexch.inbo.be>
Date: 2007-12-03T11:02:42Z
From: ONKELINX, Thierry
Subject: ggplot2: Choosing colours

Dear useRs,

I'm trying to specify the colour of a factor with ggplot2. The example
below gets me close to what I want, but it's missing a legend.

Any ideas?

Thanks,

Thierry

library(ggplot2)
dataset <- data.frame(x = rnorm(40), y = runif(40), z = gl(4, 10, labels
= LETTERS[1:4]))
ggplot(data = dataset, aes(x = x, y = y, group = z)) + geom_point(colour
= c("red", "green", "blue", "black"))


------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be 
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney