[R] assigning colors with color2D.matplot

Sumukh Sathnur sumukh.sathnur at gmail.com
Fri Aug 5 00:54:29 CEST 2011


Jim,

Thanks for the response! It turns out that using color2D.matplot 
actually eliminates my need to rotate the matrix at all. However, I'm 
not quite sure I understand the arguments for assigning colors to the 
cells. Using image and image.plot, I used col= and breaks= to define a 
certain color to a specific range of values (in my case, shades of 
gray). However, I just can't figure out how to do this in 
color2D.matplot. I mostly just don't really understand cs1 cs2 and cs3, 
and I'm more or less lost on how to reproduce the same sort of plot. 
I've only been using R for about a month, so I hope that explains my 
lack of knowledge...if you could help me out it would be much appreciated.

Thanks,
Sumukh



On 8/1/2011 2:30 AM, Jim Lemon wrote:
> On 07/30/2011 08:38 AM, 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...
>>
> Hi Sumukh,
> 1) Have a look at color2D.matplot in the plotrix package.
> 2) Have a look at color.legend in the plotrix package
> 3) Use the t (transpose) command
>
> Jim
>

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Matrix.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110804/8be0a8fd/attachment.txt>


More information about the R-help mailing list