I need to compare my treatments for each day to the control and then add percent labels to the top of the bars. I have already calculated the values and would like it to look something like this:
my code for the plot is:
corn_germ$Treatment <- factor(corn_germ$Treatment, levels= c("UTC", "B/G/G", "B/GCa/GCa", "GCa/G/G", "GCa/GCa/GCa"))
corn_germ$Day <- factor(corn_germ$Day, levels = c ("4", "5", "6", "7"), labels = c("4 DAG", "5 DAG", "6 DAG", "7 DAG"))
corn1 <- ggplot(corn_germ, aes(x=Treatment, y=PercentGermination, fill = Treatment)) +
geom_bar(stat= "identity",position = position_dodge(), width = 1, colour= "black", show.legend = FALSE) +
theme_classic() +
theme(axis.title.x = element_blank(),axis.title.y = element_text(color="black", size=16, margin = margin(r = 10)))
corn2 <- corn1 +
facet_grid(~Day, switch = "x", scales = "free_x", space = "free_x") +
theme(panel.spacing.x = unit(0, "pt"),
strip.background = element_blank(),
strip.placement = "outside", strip.text.x = element_text(size = 14,)) +
scale_x_discrete(expand=expand_scale(add=1))
corn2 <- corn2 + scale_y_continuous(breaks= pretty_breaks(), expand = c(0, 0), limits=c(0, 1.2), labels = scales::percent())+
labs(x ="Day", y = "Percent Germination")
corn3 <- corn2 + rotate_x_text(angle = 90) +
theme(strip.text.x = element_text(margin = unit(rep(10, 4), "pt")), axis.text = element_text(size = 12))
my data looks like this:
Treatment Day `Percent Germination`
<fct> <fct> <dbl>
1 B/G/G 4 DAG 1
2 B/G/G 5 DAG 10
3 B/G/G 6 DAG 10
4 B/G/G 7 DAG 10
5 B/GCa/GCa 4 DAG 3
6 B/GCa/GCa 5 DAG 9
7 B/GCa/GCa 6 DAG 9
8 B/GCa/GCa 7 DAG 9
9 GCa/G/G 4 DAG 2
10 GCa/G/G 5 DAG 10
11 GCa/G/G 6 DAG 10
12 GCa/G/G 7 DAG 10
13 GCa/GCa/GCa 4 DAG 2
14 GCa/GCa/GCa 5 DAG 7
15 GCa/GCa/GCa 6 DAG 7
16 GCa/GCa/GCa 7 DAG 10
17 UTC 4 DAG 2
18 UTC 5 DAG 8
19 UTC 6 DAG 8
20 UTC 7 DAG 8
Other questions asked seem to be looking for adding count labels, but each one of my bars only has one count which seems to be why mine isn't working.