Reputation: 1
I am trying to generate barplots with ggplot2 and want to decrease the spacing between the bars. I already decreased the bars width but now there is lots of space between the bars. Can I move the bars closer together or decrease the plots width somehow?
I found multiple people saying it's possible with position=position_dodge(width=__) as an argument in geom_bar(). For some reason, adding this and changing the number does not change anything about the plot, no error code either. This is my code for the barplot:
ggplot(t.summary, aes(Stamm, Intensitaet)) +
geom_bar(aes(fill = Stamm),
position=position_dodge(width=1), #does not work
show.legend = FALSE,
stat="identity",
alpha=0.8,
width=0.3,
color="black") +
#I added significance stars
geom_signif(data = t, comparisons = list(c("hul5d", "Hul5")),
y_position = 570, tip_length = 0.04, vjust = -0.1,
map_signif_level = TRUE) +
geom_signif(data = t, comparisons = list(c("Hul5_C878A", "Hul5")),
y_position = 200, tip_length = 0.04, vjust = -0.1,
map_signif_level = TRUE) +
geom_signif(data = t, comparisons = list(c("Hul5_C878A", "hul5d")),
y_position = 515, tip_length = 0.04, vjust = -0.1,
map_signif_level = TRUE) +
labs(x="Strains", y="Intensity compared to WT [%]") +
geom_errorbar(aes(x=Stamm, ymin=Intensitaet-sd, ymax=Intensitaet+sd),
width=0.1,
colour="black",
alpha=0.9,
size=0.5)+
scale_fill_brewer(palette = "Blues") +
theme_bw(base_size=18) +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
I figured everything else out but cannot seem to get this. Help is very appreciated!!
Upvotes: 0
Views: 432