Skip to content
Prev 274992 / 398506 Next

Scatterplot with the 3rd dimension = color?

Can someone please help me out with this? The ggplot2 suggestion works
great but I've spent a few days trying to figure out how to plot 2
variables with it and I'm stuck. Here's my example code:

library(ggplot2)
#Here's the 1st plot
x<-rnorm(100)
y<-rnorm(100)
z<-rnorm(100)
d <- data.frame(x,y,z)
dg<-qplot(x,y,colour=z,data=d)
dg + scale_colour_gradient(low="red", high="blue")

#Here's the 2nd plot which will delete the 1st plot above but I'd
like
them to be plotted together
x1<-rnorm(100)
y2<-rnorm(100)
z3<-rnorm(100)
d1 <- data.frame(x1,y1,z1)
dg1 <-qplot(x1,y1,colour=z1,data=d1)
dg1 + scale_colour_gradient(low="green", high="yellow")

I've been trying to get long format working but it just doesn't make
any sense to me.


Thanks,
kb
On Oct 17, 3:10?pm, Kerry <kbro... at gmail.com> wrote: