April 19, 2018

Changing x-axis labels in graph bar charts

The graph bar and twoway bar may seem like commands that generate the same thing: bar charts. But they are actually different, and one has advantages over the other. Similarly, one also has disadvantages over the other. You can easily use stacked charts with graph bar for example.

graph bar domgheche1 shiche1 oopche1 extche1 othche1 if country=="Philippines" ///
, ///
over(year, label(labsize(small))) ///
stack ///
outergap(75) ///
bar(1, color(ltkhaki)) ///
bar(2, color(khaki)) ///
bar(3, color(red)) ///
bar(4, color(ltblue)) ///
subtitle("Source of health expenditure, Philippines") ///
ytitle("Share (%)" " ") ///
legend(order(1 "Domestic" "government" 2 "SHI and" "compulsory" "prepayment" 3 "OOP" 4 "External" 5 "Other") pos(6) row(1) symxsize(6) size(small))


One of the problems you may encounter (especially if you chart multiple instances, years in this case, of the variables you are graphing), is getting a very crowded x-axis with the many labels (again in this case, years). One way to resolve this issue is that you can opt not to show all the labels and instead only a few. For example, you might want to show only 5-year labels (2000, 2005, 2010, and 2015). You can do this by using the relabel option (highlighted below).

graph bar domgheche1 shiche1 oopche1 extche1 othche1 if country=="Philippines" ///
, ///
over(year, relabel(2 " " 3 " " 4 " " 5 " " 7 " " 8 " " 9 " " 10 " " 12 " " 13 " " 14 " " 15 " ") label(labsize(small))) ///
stack ///
outergap(75) ///
bar(1, color(ltkhaki)) ///
bar(2, color(khaki)) ///
bar(3, color(red)) ///
bar(4, color(ltblue)) ///
nofill ///
subtitle("Source of health expenditure, Philippines") ///
ytitle("Share (%)" " ") ///
legend(order(1 "Domestic" "government" 2 "SHI and" "compulsory" "prepayment" 3 "OOP" 4 "External" 5 "Other") pos(6) row(1) symxsize(6) size(small))


Keep in mind that with graph bar, you are graphing over categorical values of the x-variable. So when relabeling, the bars are assigned the values 1, 2, 3, etc. from left to right. So you have to identify which number you are relabeling. In the example above encompassing 16 years, all categories of years are relabeled to missing except for 1 (for 2000), 6 (for 2005), 11 (for 2010), and 16 (for 2015).

Just to give you a background on the example above, the chart shows a breakdown of health expenditures by revenue source in the Philippines from 2000 to 2015. Health financing in any country can come from 5 revenue sources: (1) domestic government (a.k.a. tax revenue); (2) social health insurance and other compulsory prepayment; (3) out-of-pocket spending, or OOP; (4) external sources (international organizations and foreign governments); and (5) others (including other private sources). These charts are very important as part of monitoring trends of these sources, especially OOP. OOP is basically paying for health service directly "out of your pocket" right there and then. One of the tenets of Universal Health Coverage (UHC) is ensuring access to health care without facing financial hardship. Keep in mind, no one knows when you or your family member gets sick. So you will not only encounter a health shock, but also a financial shock if you have to pay for health care "out of your pocket."

Achieving UHC means that health care should either be financed by the government or through prepaid/pooling mechanisms such as SHI and other compulsory prepayment schemes. Using this chart, it is ideal that the OOP component (red bars) should be declining over time, while either domestic government or SHI (khaki bars) should be increasing over time. Are we seeing this in the Philippines? Unfortunately, not. We instead see the opposite.

The source of the data is World Health Organization's Global Health Expenditure Database.