I'm using ggboxplot and the "facet.by" argument. The default makes a facet horizontally, but I would like my plot to facet'ed vertically (ie. they all share the same x-axis: "Age"). I have scanned SO and other websites but haven't seen this question asked.
I have also tried filtering my dataframe by the same "facet.by" categorical variable and then using cowplot's plot_grid and gridExtra's grid.arrange function. The problem with cowplot and gridExtra is that they both remove my scale_y_beak() setting. I tried using free_y but that now creates three different y axes for my plot and I would like to apply just one y axis to all three plots.
My question: Is there a way to use the built in facet function in ggboxplot to facet by "tetramer" horizontally?
Thank you!
My code for the ggboxplot that uses the "facet.by" argument:
ggboxplot(OnlyClusterCandB, x= "time", y="Ratio_Activated_to_Unactivated", facet.by = "tetramer", fill = "tetramer", title = "Ratio of Activated insulin specific cells to
Unactivated cells over time", error.plot = "errorbar", desc_stat =
"mean_se") +
stat_summary(fun = median, geom = 'line', aes(group =
"tetramer"), position = position_dodge(width = 0.9)) +
rotate_x_text(angle = 45) +
scale_y_break(c(3,5), ticklabels =
c(0,6)) +
ylab("Ratio of activated to inactivated tetramer specific
cells") +
xlab("Age of Mice (Weeks)") + theme(legend.position =
"none") +
ggtitle("Change in activation status of circulating
tetramer specific CD4 T cells") +
theme(plot.title =
element_text(size = 16, hjust = 0.5)) +
theme(axis.text=element_text(size=14)) +
theme(axis.title.x=element_text(size=14)) +
theme(axis.title.y =element_text(size=14))