[R] Scatter plot - using colour to group points?
dwinsemius at comcast.net
Mon Nov 21 21:24:17 CET 2011
On Nov 21, 2011, at 2:17 PM, SarahH wrote:
> Dear All,
> I am very new to R - trying to teach myself it for some MSc
> I am plotting temperature data for two different sites over the same
> period which I have downloaded from a university weather station data
> I am using the following code to create the plot
> plot ( x = TEMP3[,"TIME"], y = TEMP3[,"TEMP"], type = "p", col =
> TEMP3[,"SITE"], pch = 3, main = "Temperature changes", xlab =
> "Date", ylab =
> I managed to use col = TEMP3["SITE"] to plot the two different
> sites( BG1
> and EA7) in different colours, but I am struggling to change the
> I wanted to up a colour scheme to match the site, so tried
num.site <- as.numeric(TEMP3[,"SITE"])
plot ( x = TEMP3[,"TIME"], y = TEMP3[,"TEMP"], type = "p", col =
num.site, pch = 3, main = "Temperature changes", xlab = "Date", ylab =
Would create a vector of integer values that are specific to the sites
and then offere that as argument to col=
> BG1 <- "blue"
> EA7 <- "green"
That would only have created two new objects by that name (unless of
course you were following someone's misguided directions to use
> before the plot function, but the graphic just came out with red and
> as before.
> There are other datasets in which there are more than two sites so I
> really like to learn how to use colour to distinguish between them
> on a
> Any direction would be very greatly received!
> Thank you very much
> View this message in context: http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4092794.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help