Hi Jim,

Thanks for the suggestion I will try it as I do find color2D.matplot  
is a bit more versatile.

I have however, since pasting my message, carried on playing and  
found out that that doing the following actually works as well:

 > fg = read.table("flagenes.txt", row.names=1)
 > fg1=as.matrix(fg)
 > palette=c 
("white","black","red","orange","cyan","green3","yellow","blue")
 > image(fg1, col=palette)

The only annoying thing there is that image seems to turn my data  
upside down. As yet I have not figured out how to get a legend, get  
the right types f axis labels or get the plot shown to be the correct  
orientation. This just means when I get it into Canvas for my  
presentation all I have to do is rotate it a few times and fiddle  
with it a bit more than necessary.

All the best

Phil (wragbag)

On 7 Nov 2007, at 12:13, Jim Lemon wrote:

> wragbag wrote:
>> I am a true R novice aonly using it for this function ;)
>> I am trying to use color2D.matplot to form a image of my data  
>> using the
>> following conditions
>> color2D.matplot(fi1, c(dr), c(dg), c(db), nslices=7, ylab='Species',
>> xlab="gene", show.legend=TRUE) where fi1 is my matrix.
>> I have a matrix with 36 columns and 130 rows. most entries are 1  
>> or 0 and I
>> am trying to get this function to plot these as either 0 = white  
>> or 1 =
>> black. This is fine but one column contains entries between 0 and  
>> 7. I would
>> entries between 2 and 7 to be different colors (as this is what I  
>> am trying
>> to show although I also need to see the black and white areas)  
>> using the
>> following:
>>> dr = c(1,0,1,0,0)
>>> dg = c(1,0,0,1,0)
>>> db = c(1,0,0,0,1)
>> I can get some color to work but I cannot get them all as if I but  
>> in a c()
>> range equalling 0-7 (i.e. one color for each number I get the  
>> following. I
>> cannot figure out from the documentation why it will not let me do  
>> what I
>> want :(
>> Error in rescale(x[segindex], redrange[c(seg, seg + 1)]) :    
>> rescale: can't rescale a constant vector!
> Hi wragbag,
> This is a situation that I had not envisaged in the design of  
> color2D.matplot. However, I think there is a workaround.
>
> fi1<-matrix(c(0,1),nrow=130,ncol=36)
> fi1[sample(1:3000,100)]<-sample(2:7,100,TRUE)
> color2D.matplot(fi1,
>  c(1,0,0.2,0.3,0.4,0.5,0.6,0.7),
>  c(1,0,0.2,0.3,0.4,0.5,0.6,0.7),
>  c(1,0,0.9,0.8,0.7,0.6,0.5,0.4),
>  ylab="Species",xlab="gene")
> color.legend(0,-15,7,-10,0:7,
>  color.scale(0:7,c(1,0,0.2,0.3,0.4,0.5,0.6,0.7),
>  c(1,0,0.2,0.3,0.4,0.5,0.6,0.7),
>  c(1,0,0.9,0.8,0.7,0.6,0.5,0.4))
>
> Because of the unusual way of specifying the color ranges to
> get white, black and then six colors, the rescale function
> throws an error on the constant vectors it is asked to rescale.
> I may have to think whether I can make it deal with this
> situation more gracefully. However, the above will get your
> plot and you can specify whatever colors you wish for the last
> six values in each primary color range. (What I have done is to
> specify as many color ranges as there are values).
>
> Jim

******************

Dr. Phillip Aldridge PhD.
Lecturer
Institute for Cell and Molecular Biosciences
The Medical School
Newcastle University
Framlington Place
Newcastle upon Tyne
NE2 4HH

Tel: +44-191-222-7704
Fax: +44-191-222-7424
email: [EMAIL PROTECTED]

webpage: http://www.ncl.ac.uk/camb/staff/profile/p.d.aldridge

*******************



        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to