// Combining Graphs Demo // cd "/Users/Kieuhoa/Documents/Biostat 212/" capture log close log using Vo_Demo.smcl, replace set more off version 13 clear use "/Users/Kieuhoa/Documents/Biostat 212/Neonatal Dataset for Demo.dta" graph drop _all describe, short **Combining Graphs: Histogram of BW by Sex** histogram bw if female==1, frequency /// normal /// ytitle(, size(large) margin(small)) /// xtitle("Birthweight, grams - Females") xtitle(, size(large) margin(medium)) /// xlabel(500(500)4500) /// bin (20) /// name(Lab6_hist, replace) /// saving("Lab6_histf.gph", replace) histogram bw if female==0, frequency /// normal /// ytitle(, size(large) margin(small)) /// xtitle("Birthweight, grams - Males") xtitle(, size(large) margin(medium)) /// xlabel(500(500)4500) /// bin (20) /// name(Lab6_hist, replace) /// saving("Lab6_histm.gph", replace) *Combine histograms* graph combine Lab6_histf.gph Lab6_histm.gph *Combine histograms with common Y-axis* graph combine "Lab6_histf" "Lab6_histm", ycommon *Combine histograms in columnar form* graph combine Lab6_histf.gph Lab6_histm.gph, col(1) ycommon **Box Plots of BW by Sex: Another example using simple names** graph box bw if female==1, /// ytitle("Birthweight, grams - Female", size(large) margin(medium)) /// name(female, replace) graph box bw if female==0, /// ytitle("Birthweight, grams - Male", size(large) margin(medium)) /// name(male, replace) gr combine female male, ycommon log close set more on