我正在制作一个多图图形,用于使用facet_wrap()
与ggplot2发布。 x轴标签仅显示在底部图上,这很好,但顶部图上甚至没有轴。这降低了imo的可读性,我敢肯定大多数发布者都不会这样。
如何在没有标签的情况下获得x轴?
代码:
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")