Hey Stata users
I'm trying to make a figure for a manuscript, but is it is not working for me :-( I would like the colours to be by city, but for now they are by disease. I can see why, but I dont know how to change it. Any ideas will be highly appreciated!!
Kind regards,
Jannie

This is what the data for the figure looks like :
This is the code I use for the two-way bar:
I'm trying to make a figure for a manuscript, but is it is not working for me :-( I would like the colours to be by city, but for now they are by disease. I can see why, but I dont know how to change it. Any ideas will be highly appreciated!!
Kind regards,
Jannie
This is what the data for the figure looks like :
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(proportion sd LL UL) float(DM city) byte HTN float(htn dysl) byte dmhtnlip float(ALLCON Prop SD LL100 UL100 disease concordancecity)
.223248122582039 .019453512950407845 .18507755303302637 .2614186921310516 1 1 0 . 0 0 . 22.32481 1.9453512 18.507755 26.14187 1 1
.31279889469776817 .01919783871072949 .2751299945064912 .3504677948890451 1 2 0 . 0 0 . 31.27989 1.919784 27.513 35.04678 1 2
.2509348972898948 .042974824311570486 .16661215700010007 .33525763757968957 1 3 0 . 0 0 . 25.09349 4.2974825 16.661215 33.525764 1 3
.10759384896923126 .008970016150022702 .09000458181337262 .1251831161250899 . 1 1 1 0 0 . 10.759385 .8970016 9.000458 12.518312 2 5
.1811117768846573 .010748161163981492 .16003575260715178 .2021878011621628 . 2 1 1 0 0 . 18.111177 1.0748161 16.003574 20.21878 2 6
.15317989718979885 .01930007547997531 .11533445989427478 .19102533448532294 . 3 1 1 0 0 . 15.31799 1.9300076 11.533446 19.102533 2 7
.020786662234541183 .0043265373146725815 .012302773307833432 .029270551161248933 . 1 . . 1 0 . 2.0786662 .4326537 1.2302773 2.927055 3 9
.011842849506842123 .0030410353094238235 .0058796960862410345 .01780600292744321 . 2 . . 1 0 . 1.1842849 .3041035 .5879696 1.7806003 3 10
.02066983022468096 .008174269985676571 .004640938394668132 .036698722054693794 . 3 . . 1 0 . 2.066983 .817427 .4640938 3.669872 3 11
.24501928024220415 .011760421695000219 .22195831852271034 .26808024196169794 . 1 . . . 1 1 24.50193 1.1760422 22.19583 26.808023 4 13
.33993681208878 .012513544167612134 .3153990556623092 .36447456851525084 . 2 . . . 1 1 33.993683 1.2513545 31.539906 36.447456 4 14
.27819987584370576 .02257165197316216 .2339392178844658 .3224605338029457 . 3 . . . 1 1 27.81999 2.2571652 23.39392 32.24605 4 15
end
label values city city
label def city 1 "Chennai", modify
label def city 2 "Delhi", modify
label def city 3 "Karachi", modify
Code:
gen concordancecity=city if disease==1
replace concordancecity=city+4 if disease==2
replace concordancecity=city+8 if disease==3
replace concordancecity=city+12 if disease==4
twoway (bar Prop concordancecity if disease==1) ///
(bar Prop concordancecity if disease==2) ///
(bar Prop concordancecity if disease==3) ///
(bar Prop concordancecity if disease==4) ///
(rcap LL100 UL100 concordancecity), ///
legend(row(1) order(1 "Chennai" 2 "Delhi" 3 "Karachi")) ///
xlabel( 2 "Diabetes" 6 "Hypertension" 10 "Dyslipidemia" 14 "Combined", noticks) ///
legend(ring(0) position(1) rows(1)) xtitle("") ytitle("Proportion (%)") ylabel(10 (10) 100, nogrid) graphregion( color(white))

Comment