Hi Your code is not reproducible, however you could follow this advice.
https://stackoverflow.com/questions/6085238/adding-space-between-bars-in-ggplot2 Cheers Petr > -----Original Message----- > From: R-help <r-help-boun...@r-project.org> On Behalf Of azam jaafari via > R-help > Sent: Monday, December 14, 2020 9:16 PM > To: r-help@r-project.org > Subject: [R] space between bars of a group in ggplot2 > > Hello Dear > I want to make a barplot for groups with three repetitions and same values. > dataset is like this: > > groups: a b > c > value: 1.2, 1.2, 1.2 2.5, 2.5,2.5 > Condition: sat, sat, sat, unsat,unsat,unsat, > > that bars fill based on "condition" > I used the below code: > > data%>%ggplot(aes(x=factor(groups), y=value, fill=factor(condition), > group=condition)) + > geom_bar(olour="black",stat="identity", position = position_dodge(width = > 0.8), width=0.7)+ scale_y_continuous(breaks=seq(0, 6.5, 1),limits=c(0, > 6.5),expand=c(0,0))+ scale_x_discrete(expand=c(0.000001,0))+ > theme( axis.line = element_line(colour = "darkblue", > size = 1, linetype = "solid"))+ labs(x = "group Code", > y = "Z") + > theme(panel.background = element_rect(fill = 'white'))+labs(fill = > "Condition")+ > theme(axis.text.x = element_text(face='bold',size=8, color='black', angle = > 90, vjust = 0.5)) + > theme(axis.text.y = element_text(face='bold', size=8, color='black')) > > > but it makes the connected bars (without any space between values) for each > group, while I want to add a space between bars for each value of each > group. > > Thank you for helping > BestAzam > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.