Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put black borders in heatmap in R

Tags:

r

map

heat

Hi I created a heatmap in R using "heatmap.plus" which is shown in the link

http://i.stack.imgur.com/hizBf.jpg

but I need the heat map to look like the heatmap shown in below link which was created from some other GUI software

http://i.stack.imgur.com/Y8Faj.png

How can I put black borders in every heatmap element in R

like image 602
Jana Avatar asked Feb 17 '11 22:02

Jana


2 Answers

Try this:

 library(plotrix)

 #Build a 40 Row by 40 Column Matrix
 n <- 40
 mat <- matrix(rnorm(n*n), nrow = n)

 #Plot it
 color2D.matplot(mat, cellcolors = color.scale(mat, c(0,0.5,1), c(1,0.5,0), 0))
like image 92
bill_080 Avatar answered Oct 04 '22 03:10

bill_080


Have you tried using heatmap.2? It has paramaters to do just that.

require("gplots")

data <- # matrix or data frame for your data.

heatmap.2(data, 
          sepwidth=c(0.05, 0.05),  # width of the borders
          sepcolor='black',        # color of the separation lines
          )

You may need more in the parameters depending on what you want in your graphs. R's help on the heatmap.2 function covers pretty much everything you need: ?heatmap.2

like image 25
John Mark Avatar answered Oct 04 '22 02:10

John Mark