0

I'm working on a pairs plot where I want to use hierarchical facet labels. ggpairs takes its facet labels from the column names of the input data.frame or from the columnLabels-argument. However, from these options I don't see a way to apply an extra level of column labels.

What I want: enter image description here

I know it is possible with an ordinary facet_grid plot, like in this answer, but I don't get how it would work with ggpairs.

So far, all I could think of is just splitting the names in two lines:

newlabs <- iris %>% 
  select(1:4) %>% 
  colnames() %>% 
  str_replace(pattern = '\\.', replacement = '\n')

ggpairs(iris, 
        columns = 1:4, 
        columnLabels = newlabs,
        upper = list(continuous = 'points'),
        diag = 'blank')
saQuist
  • 416
  • 7
  • 19

0 Answers0