2017-08-17 77 views
0

我想创建一个热图,但颜色键有一些白线。删除热图中的colkey中的白线

问题#1:如何去除这些白线?范围应该从-100到100.只有“0”在颜色键中应该是白色的。

问题2:如何删除列标签中的“X”?

这里是我的脚本:

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 

这里的链接数据: Data

Output Image

我感谢所有帮助。

+1

请使用'dput(dat)'并在结构中包含'structure'对象而不是外部链接 – OdeToMyFiddle

回答

1

问题1:您可以使用tidyverse包中的read_csv。它可以使用数字作为名称。

问题2:我复制了你的代码,我的图形没有白线。也许你可以增加分辨率?