Hi I would like to plot a box plot graph, with 2 categorical variables (procedure =1 and procedure =2) adjacent to each other for each category. whICH WOULD look like this:

I've used this code:
However this gives me an error
I am able to plot the two separate graph for procedure =1 and procedure =2 but these are produced on different axes as seen from this graph code
Is it possible to plot on the same axis, adjacent to each other as seen in the screenshot?
Many thanks
I've used this code:
Code:
graph box inactive_total light_total moderate_vigor_total vigorous_total, /// over(procedure, label(1 "Procedure 1" 2 "Procedure 2")) /// bar(1, fcolor(blue)) marker(1, mcolor(black)) /// bar(2, fcolor(red)) marker(2, mcolor(black)) /// bar(3, fcolor(green)) marker(3, mcolor(black)) /// bar(4, fcolor(grey)) marker(4, mcolor(black)) /// ytitle("Duration in mins/week") /// legend(order(1 "Inactive" 2 "Light Activity" 3 "Moderate Activity" 4 "Vigorous Activity") /// ring(1) row(1) pos(6)) /// note("Box plots by Procedure")
I am able to plot the two separate graph for procedure =1 and procedure =2 but these are produced on different axes as seen from this graph code
Code:
graph box inactive_total light_total moderate_vigor_total vigorous_total if procedure==1, bar(1, fcolor(blue)) marker(1, mcolor(black)) /// bar(2, fcolor(red)) marker(2, mcolor(black)) /// bar(3, fcolor(green)) marker(3, mcolor(black)) /// bar(4, fcolor(grey)) marker(4, mcolor(black)) /// ytitle(Duration in mins/week) /// legend(order (1 "Inactive" 2 " Light Activity" 3 "Moderate-to-Vigorous Activity" 4 "Vigorous Activity") ring(1) row(1) pos(6)) name(g1, replace) graph box inactive_total light_total moderate_vigor_total vigorous_total if procedure==2, bar(1, fcolor(blue)) marker(1, mcolor(black)) /// bar(2, fcolor(red)) marker(2, mcolor(black)) /// bar(3, fcolor(green)) marker(3, mcolor(black)) /// bar(4, fcolor(grey)) marker(4, mcolor(black)) /// ytitle(Duration in mins/week) /// legend(order (1 "Inactive" 2 " Light Activity" 3 "Moderate-to-Vigorous Activity" 4 "Vigorous Activity") ring(1) row(1) pos(6)) name(g2, replace) graph combine g1 g2, name(combined, replace) note("Procedure 1 vs Procedure 2")
Many thanks
Comment