[R] Adding Scale to image
jim at bitwrit.com.au
Wed Jan 31 11:05:09 CET 2007
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.
More information about the R-help