Kartik Pappu wrote: > Hello all, > > I am trying to use R to create a colored data matrix. I have my data > which (after certain steps of normalization and log transformation) > gives me a "x by y" matrix of numbers between 0 and -5. I want to be > able to create from this matrix of numbers a "x by y" image (box) that > contains x*y squares and somehow uses the value in the original matrix > to come up with a color that corresponds to the number. Hence each box > will be colored on a scale between 0 and 5. For example my data could > look like this: > > X1.FcH X2.FcH X3.FcH X4.FcH X5.FcH > X6.FcH X7.FcH > 1-AP 0.09667593 -4.66298640 -1.28299697 -4.8739017 -4.95862831 > -5.178603 -4.878524750 > 2-AP -4.69186869 -0.08547776 -4.56495440 -4.8348255 -4.80256152 > -5.121531 -4.894347108 > 3-AP -1.71380667 -4.52626124 -0.06810053 -4.8703810 -4.65657593 > -5.024595 -4.824712621 > 4-AP -4.47968850 -4.48604718 -4.44314403 -0.1569536 -4.86436977 > -4.988196 -4.550416356 > 5-AP -4.64616469 -4.53888807 -4.78163386 -4.9162949 -0.01729274 > -5.061663 -0.769960777 > 6-AP -4.61047573 -4.60917414 -4.72514817 -5.0084772 -4.87797740 > -0.284934 -1.782745357 > 7-AP -4.48157167 -4.61850313 -4.72241281 -4.8694868 -1.66122821 > -3.887898 -0.002522157 > > How do I make a 7 x 7 box that has 49 squares and each square has a > color in the RGB spectrum that corresponds to the value. So for > example in the matrix above the biggest number which is 0.00966 (at > position 1 , 1) could be set to RED and the smallest number which is > 5.0084 (at position 6, 5) can be set to BLUE and all the other numbers > be shades on a scale of Red going to Blue. > > I hope this problem makes sense. I am rather new to R and was > wondering if there was a function or solution to this problem out > there. > Hi Kartik,
Have a look at color2d.matplot in the plotrix package. Jim ______________________________________________ [email protected] 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.
