[Rd] heatmap.2 gives wrong colorkey with unequally spaced breaks (PR#14085)

From: <jorismeys_at_gmail.com>
Date: Wed, 25 Nov 2009 17:15:10 +0100 (CET)


Full_Name: Joris FA Meys
Version: 2.10.0
OS: Windows XP
Submission from: (NULL) (157.193.194.73)

I use the enhanced heatmap function in gplots : heatmap.2

For the presentation of the color key, the code is not 100% adequate. More specifically, in case you define unequally spaced breaks :

  1. the keyplot ignores the minimum and maximum of these breaks.

Code changed in line 323 and 324 to :

            min.raw <- min(c(x,breaks), na.rm = TRUE)
            max.raw <- max(c(x,breaks), na.rm = TRUE)

2) the keyplot gives the histogram with the correct breaks, but the colors remain equally spaced. This is due to the lack of a specification for x in the call to the image() function.

Code changed in line 327-328 to :

        image(x=breaks,z = matrix(z, ncol = 1), col = col, breaks = tmpbreaks,
            xaxt = "n", yaxt = "n")

Line numbers obtained by copy-pasting code from console into Tinn-R. The changed code is how I adapted the function in order to get the desired result. Don't know if it's error-proof, but it works for me.

Cheers
Joris



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 25 Nov 2009 - 20:42:01 GMT

This archive was generated by hypermail 2.2.0 : Wed 25 Nov 2009 - 21:10:47 GMT