I wanted to specify the layout of the facets when making a plot with face_wrap in ggplot, so I used the following code:
df$layout_order <- factor(rep(1:ceiling(nrow(df)/4), each = 4), levels = unique(rep(1:ceiling(nrow(df)/4), each = 4))[1:nrow(df)])
ggplot(df, aes(x = Time, y = nPVI, group = Time, fill = Group)) +
geom_bar(stat = "identity", position = "dodge", color = "black") +
labs(title = "nPVI scores by Participant, Time and Group",
x = "Time",
y = "nPVI",
group = "Time") +
facet_wrap(~ Participant + layout_order, scales = "free", ncol = 4)+
coord_cartesian(ylim = c(20, 60)) +
scale_fill_manual(values = c("Oral" = "#86CB92", "Prosody" = "#0E7C7B")) +
theme_minimal()
It works, but it also adds the layout order numbers at the top of each facet, under the Participant names. How can I remove them?
You could use
labellerper below to suppress thelayout_order.(It is better if you can supply a small amount of sample data with the question.)
Created on 2024-03-27 with reprex v2.1.0