tidyHeatmap icon indicating copy to clipboard operation
tidyHeatmap copied to clipboard

feature added: layer_symbol() supports "freetext", and add color, size options

Open frankyan opened this issue 3 years ago • 7 comments

Add freetext, color, and size to the layer_symbol() function. Then the layer_symbol() function is much more customizable. It can display values (char) in one column of the data tibble or any other freetext (char) instead of the predefined symbols. Besides, the color and size can be customized.

Here are some examples.

mtcars_tidy %>% 
  mutate(label = sprintf("%.1f", Value),
         color_label = ifelse(Value > 0, "darkred", "white")) %>% 
  heatmap(`Car name`, Property, Value, 
          palette_value = colorRamp2(c(-3, 0, 3), c("blue", "white", "red")))  %>% 
  layer_symbol(Value > 1 | Value < -1,
               symbol = "freetext", 
               freetext = label, 
               color = color_label, 
               size = 10)

image

mtcars_tidy %>% 
  heatmap(`Car name`, Property, Value, 
          palette_value = colorRamp2(c(-3, 0, 3), c("blue", "white", "red")))  %>% 
  layer_symbol(Value > 1,
               symbol = "freetext", 
               freetext = "+", 
               size = 10) %>%
  layer_symbol(Value < -1,
               symbol = "freetext", 
               freetext = "-", 
               size = 15) 

image

mtcars_tidy %>% 
  heatmap(`Car name`, Property, Value, 
          palette_value = colorRamp2(c(-3, 0, 3), c("blue", "white", "red")))  %>% 
  layer_point(Value < -1, color = "yellow")

image

frankyan avatar Jan 10 '23 14:01 frankyan

I am glad that you are interested in the additional functions. Thank you for your great guides and suggestions.

I will follow your suggestions to modify the code and reorganize the branches.

frankyan avatar Jan 11 '23 02:01 frankyan

Hello @frankyan, any luck with the process? The layer size might have come in handy for me already :)

stemangiola avatar Jan 28 '23 00:01 stemangiola

Hello. I just returned back from Chinese New Year vacation. I will try to finish it this week.

frankyan avatar Jan 30 '23 01:01 frankyan

Hello. I just returned back from Chinese New Year vacation. I will try to finish it this week.

I hope you enjoyed. No stress of course.

stemangiola avatar Jan 30 '23 02:01 stemangiola

Any news by any chance?

stemangiola avatar Mar 22 '23 10:03 stemangiola

I have started a pull request of my own inspired by yours

https://github.com/stemangiola/tidyHeatmap/pull/111

stemangiola avatar Mar 23 '23 01:03 stemangiola

FYI, from my pull request, compared with yours, I missed two features

  • size for the non-text other layers
  • colour for text and non-text layers

stemangiola avatar Mar 23 '23 06:03 stemangiola