I would like to create a bar chart using ggplot2
with dodged groups and axis labels for both the bars (male, female) and the groups (Study 1, Study 2...). Here is how I would like my chart to look:
And some R code. In this case, only the groups are labeled on the axis (not the bars within the group). The bar labels in the axis basically replace the legend.
x = runif(8)
gender = factor(c("male","female","male","female","male","female","male","female"))
group = c(0,0,1,1,2,2,3,3)
df = data.frame(x,gender,group)
ggplot(df,aes(x=group,y=x,fill=gender)) +
geom_bar(stat="identity",position="dodge") +
scale_x_continuous("",breaks=c(0:3),
labels=c('G1','G2','G3','G4'))