Skip to content

feature request: use "free text" symbol in layer_symbol(), and add color, size options #108

@frankyan

Description

@frankyan

Thank you for creating this fantastic package.

I want to display some values in the heatmap cells. Although he cell_fun or layer_fun argument from ComplexHeatmap can be added to tidyHeatmap::heatmap function to customize the display, I think it's much better and user-friendly to implement it in tidyHeatmap functions, similar to the layer_symbol() function.

The idea is to add freetext, color, and size to the layer_symbol() function. Then the layer_symbol() function is much more customizable. I have modified the code and created a pull request.
#107 (comment)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions