[R] image() and non-well-ordered colours

Robin Hankin r.hankin at noc.soton.ac.uk
Tue May 24 13:07:58 CEST 2005


I want to use image() with colours that are indexed by two variables.
Indexing by one variable is easy:

x <- seq(from=0, to=1,len=30)
z <- outer(x,1i*x,"+")

OK, so far so good.  Now, I want the colour to be a more complicated 
of z, in which both the hue and luminance change (thus the colours 
be ordered):

f <- function(z){hcl(h=100*Re(z),l=100*Im(z))}

I want to draw z in terms of the colour defined by f():


but these don't work as intended.  How do I use image() to get what I 
I can get close using plot():

x <- runif(1000)
y <- (1:1000)/10
g <- function(x){hcl(h=80*x,l=(1:1000)/10,c=300)}

[note that one cannot draw nontrivial "contour lines"  joining points 
of identical colours on this
plot: top left to lower right goes from pink to black; top right to low 
left goes from yellow to reddy orange]

It'd be nice to make image() do what I want. Anyone?

Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

More information about the R-help mailing list