Change color of the values in heatmap or remove th

2019-07-23 13:02发布

Below is my dataframe

 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

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)

enter image description here

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?

1条回答
不美不萌又怎样
2楼-- · 2019-07-23 13:21

You may just change your code as following one:

Load your data:

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")

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)

Here is the result:

enter image description here

查看更多
登录 后发表回答