[R] image question

Greg Snow Greg.Snow at imail.org
Thu Jan 24 16:34:54 CET 2008


Here is another approach that may or may not be easier:

> library(TeachingDemos)
> 
> x <- 0:4
> y <- 0:20
> 
> z <- matrix( runif(80), ncol=20 )
> 
> image(x,y,z)
> 
> clipplot( image(x,y,z, col=heat.colors(12), add=TRUE), xlim=c(0,1) )
> clipplot( image(x,y,z, col=terrain.colors(12), add=TRUE), xlim=c(1,2)
)
> clipplot( image(x,y,z, col=topo.colors(12), add=TRUE), xlim=c(2,3) )
> clipplot( image(x,y,z, col=cm.colors(12), add=TRUE), xlim=c(3,4) )
> 

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Charles C. Berry
> Sent: Wednesday, January 23, 2008 4:37 PM
> To: Ajar
> Cc: R-help at r-project.org
> Subject: Re: [R] image question
> 
> 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
> 
> ______________________________________________
> 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.
> 



More information about the R-help mailing list