Formatting issues with Heatmap.2 function in gplots library - margins and axis

Viewed 1632

I've created a heatmap in R using the heatmap2 from the gplots package and I am having awful trouble trying to format the image for use in a report.

The image represents the eigenvalues of a small correlation matrix of wavelet coefficients and I wish to represent the largest eigenvalues with a strong colour such as red and smallest using a soft yellow or similar. The colour palette isn't so much the issue it's the representation of the colours. Currently yellow represents the largest eigenvalue so I wish to reverse the order if possible.

Also is it possible to rotate the legend similar to the first image below, I've checked the help for such info but all I can find is row and column label rotation?

Ideal legend

Since my data represents a week's worth of data taken every hour, how can I change the x-axis values to show the following 12/24hr vector: 12,24,36,48,60,72,84,96,108,120,132,144,156,168. I tried setting this using cexCol but I got an error about cex.axis having the wrong length and I don't see this as an argument in heatmap2.

par(mfrow=c(1,1))
heatmap.2(eigenvalsCombined,
          trace = "none",
          dendrogram = "none",
          Rowv = NULL,
          Colv = NULL,
          density.info = "none",
          margin = c(5,7),
          main = expression(paste("Heatmap of Largest Eigenvalues ",
                                  lambda[1], 
                                  " Across 7 Wavelet Scales")),
          xlab = "Time Index (hours)",
          key = TRUE,
          lmat = rbind(c(2,3),c(4,1)),
          key.title = NA,
          key.xlab = "Eigenvalue Magnitude")

As you can see from my image below the main title is also chopped off, I have tried playing with the outer and inner margins but this doesn't have any impact either. When I use the zoom feature in the plotter and blow up the image the text appears, does this mean my formatting is correct?

enter image description here

For those interested in the data, I have posted a copy of the dput(eigenvalsCombined) to google drive for download.

2 Answers
Related