[R] Selective Plot Color

Chuck Cleland ccleland at optonline.net
Wed Jan 27 16:05:02 CET 2010


On 1/27/2010 10:00 AM, Richardson, Patrick wrote:
> Is there a way (with a simple plot) to select all observations greater than a certain value and plot them with a different color than the rest of the observations in the plot? (i.e. for all observations greater than 10, I want to plot them in red, but the rest of the observations remain black. Where can I find how to do this?
> 
> Patrick

X <- runif(30, min=5, max=15)

Y <- rnorm(30)

plot(X, Y, col=ifelse(X > 10, 'red', 'black'), pch=16)

> The information transmitted is intended only for the per...{{dropped:10}}
> 
> ______________________________________________
> 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. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894



More information about the R-help mailing list