I am trying to create a heatmap but the color key has some white lines.
Questions#1: How can I remove these white lines?The range should be from -100 to 100. Only "0" should be white in the color key.
Question#2: How can I remove the "X" in the column labels?
Here's my script:
library(gplots)
dat <- read.csv("Baguio.csv", header=TRUE)
mat_data<-data.matrix(dat)
my_palette <- colorRampPalette(c("blue","white","red"))(200)
breaks=c(seq(-100,-1,length=100),0,seq(1,100,length=100))
png("heatmap.png", # create PNG for the heat map
width = 5*300, # 5 x 300 pixels
height = 5*300,
res = 300, # 300 pixels per inch
pointsize = 8) # smaller font size
heatmap.2(mat_data,
main = "test", # heat map title
notecol="black", # change font color of cell labels to black
density.info="none", # turns off density plot inside color legend
trace="none", # turns off trace lines inside the heat map
margins =c(5,5), # widens margins around plot
col=my_palette,
breaks=breaks,
dendrogram="none",
symkey=F, xlab="Year", ylab="Date",
Colv="NA",Rowv="NA") # turn off column clustering
dev.off() # close the PNG device
Here's the link to the data: Data
I'll appreciate any help.
Question 1: you could use read_csv from tidyverse package. It can use numbers as names.
Question 2: I reproduced your code and my graphics is without white lines. Maybe you can increase the resolution?