# Re: [R] image question

From: Greg Snow <Greg.Snow_at_imail.org>
Date: Thu, 24 Jan 2008 08:34:54 -0700

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.
>

______________________________________________
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.
```
Received on Thu 24 Jan 2008 - 15:38:37 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Jan 2008 - 16:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.