I'm making a multi-plot figure for publishing with ggplot2 using facet_wrap()
. The x-axis labels only show on the bottom plots, which is perfectly fine, but there's not even an axis on the top plots. This reduces the readability imo and I'm pretty sure most publishers will not like this.
How do I get an x-axis there without labels?
My figure (with some quick example code):
The code:
library(ggplot2)
# theme settings (just to get the exact same example plot)
theme_set(theme_bw())
font <- "serif"
theme_update(axis.line = element_line(colour = "black"),
axis.title.x = element_text(size = 16, colour = 'black', family = font),
axis.title.y = element_text(size = 16, colour = 'black', family = font, angle = 90),
axis.text.x = element_text(size = 14, colour = 'black', family = font),
axis.text.y = element_text(size = 14, colour = 'black', family = font),
legend.text = element_text(size = 12, colour = 'black', family = font),
legend.title = element_blank(),
legend.position = c(0.95,0.9),
legend.box = "vertical",
strip.text.x = element_text(size = 14, colour = 'black', family = font),
strip.text.y = element_text(size = 14, colour = 'black', family = font, angle = -90),
strip.text = element_text(hjust = 1),
strip.background = element_blank(),
panel.background = element_rect(fill = "white"),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
panel.border = element_blank(),
plot.title = element_text(size = 15, face = "bold", family = font, vjust = 1, hjust = 0.5))
# example data
count <- c(10,5,6,9,2,4,8,3,1,12,5,3)
stage <- rep(c("AD","NY"),6)
treat <- rep(c("A","B","C","D"),3)
days <- c(0,7,14,21,28,35,42,49,56,63,70,77)
df1 <- data.frame(count,stage,treat,days)
# example plot
ggplot(data=df1, aes(days,count,fill=stage)) +
facet_wrap(~treat) +
geom_col(position = "dodge",color="black") +
#expand = put 0 on intersection
scale_y_continuous(expand = c(0,0), limits = c(0,15)) +
scale_x_continuous(expand = c(0,0), limits = c(0,80)) +
ylab("# per plant") +
xlab("Days after release")