0

我有一个计数数据矩阵,我想使用离散图例显示,即使我的转换数据 (log(data+1)) 是连续的。我尝试使用这行代码 ( lgd = Legend(at = 1:6, legend_gp = gpar(fill = 1:6))),但 R 返回一个“未使用”的参数。

head(data)
  2019_dry 2019_wet 2020_dry 2020_wet
1        5        0       64        0        
2        3        9        4        4       
3       38       20       49        4       
4       14       17        2        2       
5        0        0        0        0        
6        2       10        0        0      



rg<-brewer.pal(n = 8, name = "RdYlBu")

plot1<-Heatmap(as.matrix(log(data+1)),
            cluster_rows = FALSE,
            cluster_columns = FALSE,
            col = rev(rg),
        #-> lgd = Legend(at = 1:6, legend_gp = gpar(fill = 1:6)),
            rect_gp = gpar(col = "grey"),
            heatmap_legend_param = list(title = "ln(x+1)"))
4

1 回答 1

0

我发现这行代码有效:

heatmap_legend_param = list(title = "ln(x+1)", color_bar = "discrete"),...
于 2022-01-10T19:23:38.673 回答