I am having trouble getting position_dodge to work to add space between the bars. I have not been able to get any solution I've found online to work after a long time searching.
EDIT: This is not a duplicate question. That approach was one that I was unable to get to work. The other poster also used a different command to display their bars, and using the method suggested in the link did not work either.
Here is the code:
plot3 <- ggplot(PTX, aes(x=Group, y=Percent.Baseline, group = Group)) +
stat_summary(fun.data="mean_cl_normal", geom = "errorbar", position = position_dodge(width = 10), width = 0.3, size = 1.2) +
stat_summary(fun.y="mean", geom="bar",fill = "white", color = "black", position_dodge(width = 10), size = 2) +
geom_point(data = PTX, name = "Estrous Cycle", aes(shape = PTX$Estrous.Cycle, color = PTX$Estrous.Cycle),
alpha = 1, size = 10.4, stroke = 3, show.legend=TRUE) +
scale_shape_manual(name = "Estrous Cycle",
values=c(0, 1, 2),
labels=c("Proestrous", "Estrous", "Diestrous")) +
scale_x_discrete(limits=c("HC", "ES", "IS")) +
scale_y_continuous(breaks=c(40,60,80,100,120)) +
coord_cartesian(ylim=c(43.8,120)) +
scale_colour_manual(name = "Estrous Cycle",
labels = c("Proestrous", "Estrous", "Diestrous"),
values = c("navyblue", "darkgreen", "darkred")) +
theme(panel.border = element_blank(),
legend.key = element_rect(fill = NA, colour = NA, size = 0.25),
axis.line = element_line(size = 2.5, linetype = "solid",
colour = "black"),
panel.background = element_rect(fill = "transparent", color="NA"),
axis.text.x = element_text(colour="grey20",size=24,hjust=.5,vjust=.5,face="bold"),
axis.text.y = element_text(colour="grey20",size=24,hjust=1,vjust=0,face="bold"),
axis.title.x=element_blank(),
axis.title.y=element_text(face="bold", size=40, color = "black"),
axis.ticks.y = element_blank(),
legend.key.height=unit(3.2, "line"),
legend.key.width=unit(3.2, "line"),
legend.title=element_text(size=21),
legend.text=element_text(size=21))
plotfinal <- plot3 + ylab("% Baseline")
plotfinal
Here is what the plot looks like now: