[R] problems with image.plot()

David Winsemius dwinsemius at comcast.net
Sat Jul 30 02:23:51 CEST 2011

On Jul 29, 2011, at 6:38 PM, Sumukh Sathnur wrote:

> Hi all,
> I used image.plot() to create a heat map of a matrix:
> as.matrix(read.table("Matrix.txt", sep="\t"))->x
> HeatBrk<-seq(5,25,2.5)
> MyCol= gray((7:0)/7)
> library(fields)
> image.plot(x, col=MyCol, breaks=HeatBrk, legend.shrink=0.3)
> dev.copy(device=pdf, file="HEAT4!.pdf", height=8, width=8)
> dev.off()
> There are a few things that I would like to do that I can't seem to  
> find help with online:
> 1) Add axes to the bottom and left that go from 1:ncol(x) ; in this  
> case, 104. Every time I try to add axes in some form or another they  
> either go through the center of the image or do not show up at all.
> 2) Limit the scale of the legend from the minimum value to the  
> maximum value that I assign a color to; as of now it goes from the  
> minimum value (0) to the maximum value (300) but I would like it to  
> stop at 25.
> 3) Rotate the resulting image 90 degrees to the right. Is there a  
> generic way to do this? everything I have found online is case- 
> specific and extremely complicated...

I don't have time to address the complte set of questions but wouldn't  
this last one be easily handled by reversing the x and y arguments to  

-- David.

> I know this is a lot to ask, but I've been stuck on these for a few  
> days and I can't seem to figure them out. Any help would be  
> appreciated.
> Thanks in advance,
> Sumukh
> <HEAT4!.pdf><Matrix.txt>______________________________________________
> 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, MD
West Hartford, CT

More information about the R-help mailing list