【问题标题】:Removing white lines in colkey of a heatmap去除热图 colkey 中的白线
【发布时间】:2017-08-17 08:26:18
【问题描述】:

我正在尝试创建热图,但颜色键有一些白线。

问题#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

我将不胜感激。

【问题讨论】:

  • 请使用dput(dat) 并在帖子本身中包含structure 对象,而不是外部链接

标签: r heatmap gplots


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-14
    • 1970-01-01
    • 2012-03-24
    • 2017-06-22
    相关资源
    最近更新 更多