[R] image and color gradient

David Winsemius dwinsemius at comcast.net
Fri May 17 22:22:30 CEST 2013


On May 17, 2013, at 12:58 PM, Hermann Norpois wrote:

> Hello,
> 
> I have a nice function that makes an image of an matrix
> e.g.:
> qt[1:3,1:3]
>             rs655246     rs943795 rs955612
> rs655246           NA           NA       NA
> rs943795 9.610070e-04           NA       NA
> rs955612 5.555616e-05 7.915982e-07       NA
> 

If you had used dput to offer that test case I would have tested my suggestions. As it is I will simply suggest:

... ,  breaks=10^-(0:8), ...

You will need to specify the colors to match the breaks.

> 
> myimage <- function(x, cex.axis = 0.7, ...){
>  opar <- par(mar=c(5,4,4,6),
>              pty ='s')
>  on.exit(par(opar))
>  image(x, axes = FALSE, ...)
>  ats <- 0:(nrow(x)-1)/(nrow(x)-1)
>  axis(1, at=ats, lab=rownames(x), cex.axis=cex.axis, las=2)
>  axis(4, at=ats, lab=colnames(x), cex.axis=cex.axis, las=2)
>  box()
> }
> 
> The ranges in my matrix are from 1 to 1e-08. But in my image there is no
> difference between, for instance 1e-05 and 1e-06 or -07 etc.
> 
> How can I ameliorate my function myimage to do so. I guess it has something
> to do with breaks but I do not understand how to handle.
> Thanks
> Hermann
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list