Dear statalist,
I have a problem of plotting a bar chart in STATA. I have 3 categorical variables, and I'd like to count var1 over var2 by/over var3 (it's somehow like visualize a 2x2 table in bar graph). In details, my commands are like below:
graph bar (count), over(var1, label(angle(45))) over(var2) blabel(bar) ytitle("xxx") by(var3, title("xxx")) legend(on)
And the graph will like this:
But I want to the color of each bar different to be different like this:

I made the latter one by changing the by(var3) into over(var3), But it turns out that the legend of each color (or bar?) will not able to display like the former one.
And also, I'm wondering if there is a way to combine the values of two sex? Like to overlay them to make the difference of each bar between sex in each group more visible?
Thank you so much.
I have a problem of plotting a bar chart in STATA. I have 3 categorical variables, and I'd like to count var1 over var2 by/over var3 (it's somehow like visualize a 2x2 table in bar graph). In details, my commands are like below:
graph bar (count), over(var1, label(angle(45))) over(var2) blabel(bar) ytitle("xxx") by(var3, title("xxx")) legend(on)
And the graph will like this:
But I want to the color of each bar different to be different like this:
I made the latter one by changing the by(var3) into over(var3), But it turns out that the legend of each color (or bar?) will not able to display like the former one.
And also, I'm wondering if there is a way to combine the values of two sex? Like to overlay them to make the difference of each bar between sex in each group more visible?
Thank you so much.
Comment