0

I have a heatmap:

library(tidyverse)
df = data.frame(V1 = letters[1:10], V2 = letters[11:20], estimate = rnorm(10), meta_group = c(rep("class_1", 3), rep("class_2", 2), rep("class_3", 5)))

df %>%
    ggplot(aes(x=V1, y=V2, fill=estimate)) +
    geom_tile()

enter image description here

I would like the x-axis labels to be the corresponding values in meta_group, but for a single label to span the entire range of x-axis values for that meta_group value. Like this ("c2" should be "class_2" I just ran out space):

enter image description here

How can I achieve this?

user438383
  • 5,716
  • 8
  • 28
  • 43
  • Please see the responses to this question, there are two solutions proposed there: https://stackoverflow.com/questions/23207878/ggplot2-group-x-axis-discrete-values-into-subgroups – nrennie Feb 24 '23 at 14:21
  • Yeah faceting worked, thanks. – user438383 Feb 24 '23 at 14:32

0 Answers0