[R] image question

Charles C. Berry cberry at tajo.ucsd.edu
Thu Jan 24 00:37:09 CET 2008


On Wed, 23 Jan 2008, Ajar wrote:

> Hi,
>
> I have a question regarding the image function. Is there a way to
> specify a separate color set for each column in the matrix?

Yes. But it will require some attention to the scaling of your matrix.

This shows how it might be done:

> mat <- matrix( runif(100), nc=10)
> image( mat + rep( 1:2, each=50),col=c(topo.colors(10),heat.colors(10)))

Add an offset to the matrix to choose a different color scheme.

Of course, the step size for the offset needs to be greater than or equal 
to the range of values that you are representing.

You will need to specify zlim to be sure this works right.

HTH,

Chuck

>
> TIA,
> ajar.
>
> ______________________________________________
> 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.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901



More information about the R-help mailing list