Hi, I want to put spaces between each pair of bars in my barplot.
This is my code
ggplot(Germ, aes(x = G, y = T,
color = c('WT', 'at5g01950')[2 - (as.numeric(G) %% 2)])) +
geom_bar(position="dodge", stat="identity") +
geom_boxplot(width = 0.5, color = "black", alpha = 0.2,
position = position_dodge(0.9)) +
theme_minimal() +
theme(plot.background = element_rect(fill = "white") ,
panel.grid.minor = element_blank()) +
labs(color = '')
This is my barplot
It would be nice to add the space of a bar, or even less, bewteen, for example, bars pairs 1,2 and 3,4, and so on.
Thank you
2 answers
This is a general R question and not related to bioinformatics, thus is likely better for stackoverflow. After a quick google search you likely want to tinker with the width parameter within the geom_bar layer. See this SO post: https://stackoverflow.com/questions/6085238/adding-space-between-bars-in-ggplot2
this isn't really a bioinformatics question, but you alter the distances using both position=position_dodge(width=0.5) and width=0.5 in your boxplot and bar geometries.
Also, to properly dodge and color the bars create a column with the group and then just pass the column name to fill= in the aesthetics function of ggplot.
Log in to answer this question.
Why is it that you thanked me for the post that told you to search online, then deleted it and asked a similar question? You see how the other users here has also asked you to search online, right? Please stop this behavior.