221B
221B

Reputation: 851

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

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?

Upvotes: 1

Views: 1023

Answers (1)

Scipione Sarlo
Scipione Sarlo

Reputation: 1498

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

Upvotes: 1

Related Questions