I’m trying to improve the visualization of this figure by separating the x-axis into nested subcategories of samples. I’m not able to use ggplot fill for this since I’ve already used pivot_longer() to include 6 types of output. The solution also has to allow a free scale view using facet_wrap() to examine trends between individual protein components.
Current figure
Desired figure
facet_wrap with free y-axis (pardon the x-axis labels, I’ve tried to conceal my actual data)
Data frame:
`head(data)
ShortName Mod Growth Day Group Conc
1 CTRL_D02 CTRL CC 2 Protein1 0.013072917
2 CTRL_D02 CTRL CC 2 Protein2 0.000000000
3 CTRL_D02 CTRL CC 2 Protein3 0.004661458
4 CTRL_D02 CTRL CC 2 Protein4 0.000000000
5 CTRL_D02 CTRL CC 2 Protein5 0.000000000
6 CTRL_D02 CTRL CC 2 Protein6 0.025885417
separate plots by growth condition
CC <- data %>% slice(1:144)
LG <- data %>% slice(145:210)`
ggplot, stacked bar graph to view broad quantity of all proteins
p0 <- ggplot(CC) + geom_col(aes(x = ShortName, y = Conc, fill = Group)) + theme_clean() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) + labs(y = "Concentration", x = "Sample", fill = "Composition")
ggplot, view trends of individual protein components
p0.1 <- p0 + facet_wrap(. ~ Group, scales = "free_y") + theme(legend.position="none")
Thank you for your help!