I have a plot like this below:
library(ggplot2)
library(ggh4x) # remotes::install_github("teunbrand/ggh4x")
df1 <- data.frame(x = rep(1:12, times=4, each=1),
y = rep((1:12)^2, times=4, each=1),
Variable1 = rep(c("A","B"), times=1, each=24),
Variable2 = rep(c("C","D"), times=4, each=12))
g<-ggplot(df1, aes(x=x, y=y)) +
geom_point(size=1.5) +
theme(strip.background = element_rect(colour = "black", fill = "white",
size = 1.5, linetype = "solid"),
axis.title.x =element_text(margin = margin(t = 2, r = 20, b = 0, l = 0),size = 16),
axis.title.y =element_text(margin = margin(t = 2, r = 20, b = 0, l = 0),size = 16),
axis.text.x = element_text(angle = 0, hjust = 0.5,size = 14),
axis.text.y = element_text(angle = 0, hjust = 0.5,size = 14),
strip.text.x = element_text(size = 14),
strip.text.y = element_text(size = 13),
axis.line = element_line(),
panel.grid.major= element_blank(),
panel.grid.minor = element_blank(),
legend.text=element_text(size=15),
legend.title = element_text(size=15,face="bold"),
legend.key=element_blank(),
legend.position = "right",
panel.border = element_blank(),
strip.placement = "outside",
strip.switch.pad.grid = unit('0.25', "cm")) +
facet_nested( .~Variable1 + Variable2)
g
How could I increase the space among different boxes for the different facet labels? So for example, I want to increase the space between A
and C/D
. In this post is explained how to change the distance between the plot edge and the facet labels (using strip.switch.pad.grid
in theme
), but it doesn't work for separating facet boxes among them.
Does anyone know how to do it?
facet_nested
from please – Capitolfacet_nested
comes from the packageggh4x
. And regarding the question, yes, I want to increase space betweenA
andC
orA
andD
. – Hawserfacet_nested
, which is the only function which allows the alignment of different facet boxes as far as I know. – Hawser