Use of colour in plots
Hi r-help-bounces at r-project.org napsal dne 05.09.2008 16:24:35:
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) ===========================================================
Or third <- (z$y >=.5)+1 plot(z, col=third, pch=16) Just tell to col a vector of colors with appropriate use of logical. Or you can use col = as.numeric(some factor), which is quite convenient use of factors feature which is not desired in other cases. See warning section of factor help page. Regards
--- 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.
______________________________________________ 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.