Hello Stata users,
I want to add the mean of two variables (meanEI EER) in the boxplot (see attached gragh). My code for the box plot is:
I read that the scatter option need to be added including new variables for mean:
Stata returns an error saying "box is not a twoway plot type".
Can someone please tell me how I can make it work?
I am using Stata 12
I want to add the mean of two variables (meanEI EER) in the boxplot (see attached gragh). My code for the box plot is:
Code:
graph box meanEI EER, /// title("Graph 4.1: Mean energy intake and estimated energy requirement", size(medium)) /// subtitle("Infants and young children under 96 months",size(medsmall)) /// ytitle ("Kcal", size(medsmall) margin(medium)) /// ylab(500 1000 1500 2000 2500 3000, angle(horizontal)) /// box(1, color(navy8)) marker(1, mcolor(navy8) msize(small)) /// box(2, color(green)) marker(2, mcolor(green) msize(small)) /// intensity(75) lintensity(100) graphregion(color(white)) /// scheme(s2color) legend(order( 1 "Mean EI (Kcal/d)" 2 "EER (Kcal/d)")) /// note("EI = energy intake; EER = estimated energy requirement")
Code:
egen med2 = mean(meanEI) egen med3 = mean(EER) twoway (box meanEI EER) /// (scatter med2 med3) /// title("Graph 4.1: Mean energy intake and estimated energy requirement", size(medium)) /// subtitle("Infants and young children under 96 months",size(medsmall)) /// ytitle ("Kcal", size(medsmall) margin(medium)) /// ylab(500 1000 1500 2000 2500 3000, angle(horizontal)) /// box(1, color(navy8)) marker(1, mcolor(navy8) msize(small)) /// box(2, color(green)) marker(2, mcolor(green) msize(small)) /// intensity(75) lintensity(100) graphregion(color(white)) /// scheme(s2color) legend(order( 1 "Mean EI (Kcal/d)" 2 "EER (Kcal/d)")) /// note("EI = energy intake; EER = estimated energy requirement")
Can someone please tell me how I can make it work?
I am using Stata 12
Comment