I am trying to create a barplot where for each category, two bars are plotted (side by side): one is for the \"total\", the other is stacked by subgroups. For example, in th
You can also increase the width of the bars to better fit the figure. Try this:
p = ggplot(df, aes(x=factor(names)), ) +
geom_bar(width=0.75,data=subset(df,num=="total"), aes(y=values), stat="identity",width=.5) +
geom_bar( width=0.75, data=subset(df,num!="total"), aes(y=-values,fill=factor(num)), stat="identity",width=.5)
print(p)
EDIT:
I think I misunderstood your question. Do you want the bars within one name to be side by side?