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...@gmail.com> wrote: > Yes, the qplot works great, but do you know how to allow for multiple > plots? I want one variable to be plotted say from blue to red and > another say from yellow to green but in the same graph, each having > there own separate legends. I've tried print() and arrange() but no > luck. > > Thanks again, > kb > > On Oct 2, 10:42 pm, Ben Bolker <bbol...@gmail.com> wrote: > > > > > > > > > > > Duncan Murdoch <murdoch.duncan <at> gmail.com> writes: > > > > On 11-10-02 1:11 PM, Kerry wrote: > > > > I have 3 columns of data and want to plot each row as a point in a > > > > scatter plot and want one column to be represented as a color gradient > > > > (e.g. larger values being more red). Anyone know the command or > > > > package for this? > > > > It's not a particularly effective display, but here's how to do it. Use > > > rainbow(101) in place of rev(heat.colors(101)) if you like. > > > > x <- rnorm(10) > > > y <- rnorm(10) > > > z <- rnorm(10) > > > colors <- rev(heat.colors(101)) > > > zcolor <- colors[(z - min(z))/diff(range(z))*100 + 1] > > > plot(x,y,col=zcolor) > > > or > > > d <- data.frame(x,y,z) > > library(ggplot2) > > qplot(x,y,colour=z,data=d) > > > I agree about the "not particularly effective display" > > comment, but if you have two continuous predictors and > > a continuous response you've got a tough display problem -- > > your choices are: > > > 1. use color, size, or some other graphical characteristic > > (pretty far down on the "Cleveland hierarchy") > > 2. use a perspective plot (hard to get the right viewing > > angle, often confusing) > > 3. use coplots/small multiples/faceting (requires > > discretizing one dimension) > > > ______________________________________________ > > r-h...@r-project.org mailing > > listhttps://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.