Skip to content

Scatter plot - using colour to group points?

1 message · John Kane

#
Another approach would be to use ggplot2.? 
Code can look a bit daunting to begin with but ggplot2 is a 
very versitile graphing package and well worth learning.

Simple example
=============================================================
library(ggplot2)
mydata <- data.frame(site=c("A","A","A", "B","B","B"), time1 = 1:6, t1=c(23,24,13,7,19,12),
                        t2=c(7, 4,6,8,5,9))
       
p <- ggplot(mydata, aes(x=time1)) +
    geom_point(aes(y= t1, colour= site)) +
     geom_point(aes(y = t2, colour=site))

p   <- ggplot(mydata, aes(x=time1)) +
    geom_point(aes(y= t1, colour= site)) +
     geom_point(aes(y = t2, colour=site))
     
p <- p + scale_x_continuous('Time')+
              scale_y_continuous('Temperature')

p
=============================================================
--- On Mon, 11/21/11, SarahH <sarah.g10 at hotmail.co.uk> wrote: