79194146

Date: 2024-11-15 22:47:55
Score: 1.5
Natty:
Report link

I just add geom_subtile() and geom_subrect() function in package ggalign to subdivide rectangles with shared borders into a grid.


df <- tibble::tibble(
    id = c(LETTERS[1:6], LETTERS[1:5]),
    value = c(paste0("V", 1:6), paste0("V", 1:5)),
    group = c(rep("group_1", 6), rep("group_2", 5))
)
library(ggalign)
ggplot(df, aes(x = id, y = value, fill = group)) +
    geom_subtile()

enter image description here

It can do more:

## arranges by row
ggplot(data.frame(value = letters[seq_len(5)])) +
    geom_subtile(aes(x = 1, y = 1, fill = value))

enter image description here

## arranges by column
ggplot(data.frame(value = letters[seq_len(9)])) +
    geom_subtile(aes(x = 1, y = 1, fill = value), byrow = FALSE)

enter image description here

## one-row
ggplot(data.frame(value = letters[seq_len(4)])) +
    geom_subtile(aes(x = 1, y = 1, fill = value), direction = "h")

enter image description here

## one-column
ggplot(data.frame(value = letters[seq_len(4)])) +
    geom_subtile(aes(x = 1, y = 1, fill = value), direction = "v")

enter image description here

Reasons:
  • Probably link only (1):
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Yun