答案 0 :(得分:1)
你的意思是使用facetting这样的东西吗?
# Sample data
set.seed(123);
df <- cbind.data.frame(
y = rnorm(20),
Group = sample(c("UT", "F", "T"), 20, replace = TRUE),
x = sample(c("Follow-up 1", "Follow-up 2"), 20, replace = TRUE))
# Plot
gg <- ggplot(df, aes(x = x, y = y, fill = Group));
gg <- gg + geom_boxplot();
gg <- gg + facet_wrap(~ x, ncol = 3, scales = "free_x");
gg <- gg + theme(
axis.text.x = element_blank(),
axis.ticks.x = element_blank());
gg <- gg + labs(x = "x axis label", y = "y axis label");
在x轴上使用组标签
gg <- ggplot(df, aes(x = Group, y = y, fill = Group));
gg <- gg + geom_boxplot();
gg <- gg + facet_wrap(~ x, ncol = 3, scales = "free_x");
gg <- gg + labs(x = "x axis label", y = "y axis label");