Dear all, I have 3 datasets all of which share the same longitude and latitude values, which I'm looking to plot onto a scattergraph. The third dataset has values which can only be either '1' or '2'. So to incorporate all three datasets onto two axes, I'm wondering if I can plot dataset1 and dataset2 as normal, but then use colour to determine whether these points are either values '1' or '2' according to the third dataset. If so, how would I go about doing this in R, and what format would the command take? Thanks for any help offered, Steve
Here is an example doing the same type of thing. It should be easy enough to adapt. Good luck ==========================================================x <- runif(100, 0, 1) y <- runif(100, 0, 1) z <- data.frame(x,y) plot(subset(z, z$y >=.5), col="red", ylim=c(min(z$y), max(z$y)), pch=16) points(subset(z, z$y <=.49), col="blue", pch=16) ========================================================== --- On Fri, 9/5/08, Steve Murray <smurray444 at hotmail.com> wrote:> From: Steve Murray <smurray444 at hotmail.com> > Subject: [R] Use of colour in plots > To: r-help at r-project.org > Received: Friday, September 5, 2008, 9:10 AM > Dear all, > > I have 3 datasets all of which share the same longitude and > latitude values, which I'm looking to plot onto a > scattergraph. The third dataset has values which can only be > either '1' or '2'. So to incorporate all > three datasets onto two axes, I'm wondering if I can > plot dataset1 and dataset2 as normal, but then use colour to > determine whether these points are either values '1' > or '2' according to the third dataset. > > If so, how would I go about doing this in R, and what > format would the command take? > > Thanks for any help offered, > > Steve > > ______________________________________________ > R-help at 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.
Jim, Thanks for this - I've looked into cluster.overplot in particular which, judging by the help file, sounds quite useful (count.overplot seems less relevant). I'm finding however, that when I execute cluster.overplot, it simply returns many values (which total the number in the dataset I'm using, 54041), but doesn't produce, or alter my graph! Is this to be expected? If so, what do the ouput values represent? Because not *all* of the values overplot, so I'm confused as to why the number of cluster.overplot output values equals the number of values in my dataset! Thanks, Steve ----------------------------------------> Date: Fri, 19 Sep 2008 21:57:03 +1000 > From: jim at bitwrit.com.au > To: smurray444 at hotmail.com > Subject: Re: [R] Use of colour in plots > > Steve Murray wrote: >> Greg, >>[[elided Hotmail spam]]>> >> One (hopefully final!) question I have is, is there any way of preventing overplotting? I'm finding that many of the red points are being obscured by the greens - I've tried making the point sizes small (cex=0.1) but this doesn't fully solve the problem. >> >> Or even, is there a way of changing the order of which the points are plotted? >> > Hi again, > Maybe cluster.overplot or count.overplot in the plotrix package? > > Jim >