Dear List, I have used the image() function to show a heat plot of a matrix of data whose intensity is color-coded. I have two questions that I have not been able to solve by using the help system or google. 1) How can one add a scale/legend that shows what numerical values a given color corresponds to? 2) How can one "flip" the rows (i.e., change the order of the rows in the image plot)? Thanks very much in advance, Peter -- Dr. med. Peter N. Robinson, MSc. Institut f?r Medizinische Genetik Universit?tsklinikum Charite Humboldt-Universit?t Augustenburger Platz 1 13353 Berlin Germany voice: 49-30-450569124 fax: 49-30-450569915 email: peter.robinson at charite.de http://www.charite.de/ch/medgen/robinson
Dr. med. Peter Robinson wrote:> > I have used the image() function to show a heat plot of a matrix of data > whose intensity is color-coded. I have two questions that I have not > been able to solve by using the help system or google. > > 1) How can one add a scale/legend that shows what numerical values a > given color corresponds to? >by plotting one more sequence of points For example layout(matrix(c(1,2)),heights=c(0.9,0.1)) image( blah blah blah ) plot.new() plot.window(xlim=c(0,100),ylim=c(0,1)) points(x=0:100,y=rep(1,101),col=heat.colors(101),pch=15,cex=2) Dr. med. Peter Robinson wrote:> > 2) How can one "flip" the rows (i.e., change the order of the rows in > the image plot)? >By flipping the source matrix, displayed with "image" image(matrix.result[nrow(matrix.result):1,]) -- View this message in context: http://www.nabble.com/-R--Adding-Scale-to-image-tf3142258.html#a8709150 Sent from the R help mailing list archive at Nabble.com.
Peter Robinson wrote:> Dear List, > > I have used the image() function to show a heat plot of a matrix of data > whose intensity is color-coded. I have two questions that I have not > been able to solve by using the help system or google. > > 1) How can one add a scale/legend that shows what numerical values a > given color corresponds to?You can use the gradient.rect function in the plotrix package to display a rectangular bar with a specified number of color "slices" in it. For an example of how to make this into a color legend, see the color2D.matplot function in the same package. If this is of interest to R users, I could include a color.legend function in plotrix that would do it all. Jim
"image.plot" from "fields" plots an image and a legend (or scale) Dr. med. Peter Robinson wrote:> > I have used the image() function to show a heat plot of a matrix of data > whose intensity is color-coded. > > 1) How can one add a scale/legend that shows what numerical values a > given color corresponds to? >-- View this message in context: http://www.nabble.com/-R--Adding-Scale-to-image-tf3142258.html#a8727371 Sent from the R help mailing list archive at Nabble.com.