更改热图中值的颜色或删除highcharter R程序包中的值 [英] Change color of the values in heatmap or remove the values in highcharter R package
本文介绍了更改热图中值的颜色或删除highcharter R程序包中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的数据框
df
a b c d
1 0 0 0 0
2 0 0 0 1
3 0 0 0 0
4 0 1 0 0
这是生成热图的代码.它使用R中的highcharter库.
Here is the code which generated heatmap. It uses the library highcharter in R.
hchart(as.matrix(df), "heatmap", hcaes(x = variable, y = name, value = value)) %>% hc_colorAxis(stops = color_stops(2, c("yellow","blue")))%>%hc_size(height = 500)
我的问题是,如何更改热图中显示的值/数字的颜色.或者,如何从热图中删除值?
My question is, how can I change color of the values/numbers that are being displayed in the heatmap. OR, how do I remove the values from heatmap?
推荐答案
您可以将代码更改为以下代码:
You may just change your code as following one:
加载数据:
mydf <- structure(list(a = c(0L, 0L, 0L, 0L), b = c(0L, 0L, 0L, 1L),
c = c(0L, 0L, 0L, 0L), d = c(0L, 1L, 0L, 0L)), .Names = c("a",
"b", "c", "d"), row.names = c("1", "2", "3", "4"), class = "data.frame")
然后,生成热图并更改颜色修改ng color_stops
参数:
Then, produce the heatmap and change the color modifyng color_stops
argument:
hchart(as.matrix(mydf)) %>%
hc_colorAxis(stops = color_stops(2, c("white","red"))) %>%
hc_size(height = 500)
这是结果:
这篇关于更改热图中值的颜色或删除highcharter R程序包中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文