[R] different color indicates difference magnitude

Marc Girondot marc_grt at yahoo.fr
Wed Mar 13 10:06:33 CET 2013


> On 13/03/13 10:20, meng wrote:
>> Hi all:
>> Is there a plot tool to use different color indicates difference 
>> magnitude of data?
>> The plot is in the attachment.
>>
>> Many thanks.
No sure what you want exactly as there is no attachment here.
Here are an example of what can be done:

x <- 1:128
y <- rnorm(128, 10, 2)

z <- x+y

nbcol <- heat.colors(128)

# standardize z to be from 1 to 128
zcol <-  ((z-min(z))/(max(z)-min(z)))*127+1

# different examples
plot(x, y, col=nbcol[zcol], pch=".", cex=10, bty="n")
plot(x, y, col=nbcol[zcol], pch=".", cex=zcol/10, bty="n")
plot(x, y, col=nbcol[128-zcol], pch=".", cex=10, bty="n")

Sincerly

Marc


-- 
__________________________________________________________
Marc Girondot, Pr

Laboratoire Ecologie, Systématique et Evolution
Equipe de Conservation des Populations et des Communautés
CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
Bâtiment 362
91405 Orsay Cedex, France

Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53
e-mail: marc.girondot at u-psud.fr
Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
Skype: girondot



More information about the R-help mailing list