I would like to produce the graph as in this
Here is the data:
dat <- data.frame(Species = rep(rep(c("DC", "DP"), each = 2), 3),
ES = rep(c("CA", "CK", "HD"), each = 4),
W = rep(c("S", "D"), 6),
P = c(0.5, 0.77, 0.003, 0.43, 0.38, 0.68, 0.003, 0.26, 0.13, 0.05, 0.003, 0.04))
What I had achived is this...
dat %>%
ggplot(aes(x=Species, P*100, fill = Species)) +
scale_fill_manual(values = c("dodgerblue1", "springgreen3"),
labels = c("Dreissena carinata", "Dreissena polymorpha"))+
geom_col(position = position_dodge2(width = 0.9, reverse = TRUE))+
facet_wrap(~ES, nrow = 1)+
geom_text(aes(label = scales::percent(P, accuracy = 1)),
position = position_dodge2(width = 1.9, reverse = F),
vjust = - 0.5,
hjust= 0.5,
colour = "black",
size = 2.5)+
scale_y_continuous(limits = c(0, 100))+
theme_gray()+
labs(x = " ",
y = "Infection Prevalence %",
title = "Test #2020_001",
subtitle = "Infection Prevalence at the Start (S) and During (D) the Test"
) +
theme(plot.title = element_text(hjust = 0.5),
axis.text.x = element_text(face="italic", size=0),
axis.title.y = element_text(face="bold", colour="black", size = 10, family = "Helvetica"),
strip.text.y = element_text(face = "bold"),
strip.text = element_text(face= "italic", size = 9, family = "Helvetica"))+
theme(legend.position = "bottom",
legend.title = element_text(size=0),
legend.text = element_text(face= "italic", size = 10, family = "Helvetica", margin = margin(r = 20, unit = "pt")),
legend.spacing.x = unit(2, "mm"),
legend.key.size = unit(5, "mm"),
legend.box.spacing = unit(-5, "mm"),
plot.title = element_text(face="bold", colour="black", size = 11, hjust = 0, family = "Helvetica"),
plot.subtitle = element_text(size = 9, hjust = 0, family = "Helvetica"),
axis.ticks = element_blank(),
panel.grid.major.x = element_blank(),
panel.spacing = unit(5, "mm"))
What I would like to ask you is to place the labels "S" and "D" at the bottom of the bars and not to use photoshop anymore .
Thank you in advance..