Dear Statalisters,
The following graph was obtained using the code below in Stata/SE 14.2. The data is on per capita households and government consumption for 20 countries in the year 2017. Is there a way to sort the stacked bars based on the sum of the two variables displayed: pc_cpd "Households consumption" and pc_cgd "Government consumption" instead of doing the sorting based on one of them?
Many thanks.
The following graph was obtained using the code below in Stata/SE 14.2. The data is on per capita households and government consumption for 20 countries in the year 2017. Is there a way to sort the stacked bars based on the sum of the two variables displayed: pc_cpd "Households consumption" and pc_cgd "Government consumption" instead of doing the sorting based on one of them?
Code:
graph hbar (asis) pc_cpd pc_cgd , over(country, sort(1) descending) /// blabel(bar, position(base) format(%4.1f)) stack nofill scheme(s1color) subtitle(, fcolor(white)) /// title("Per capita consumption in Arab Countries 2017") subtitle((US dollars/day)) name(consumption)
Many thanks.
Comment