Change color of the values in heatmap or remove the values in highcharter R package

旧时模样 提交于 2019-12-11 04:18:38

问题


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)

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:


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:



来源:https://stackoverflow.com/questions/48019176/change-color-of-the-values-in-heatmap-or-remove-the-values-in-highcharter-r-pack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!