When creating a horizontal bar graph, the default behavior seems to be to align the labels with the middle of the bars. For example:
Results in:

You can see that the labels "single" and "married" are approximately aligned to be in the center of the bars.
However, when you have enough variables with a large enough label size, the labels are no longer aligned with the middle, and seem to be shifted down. For example:
Results in:

Here you can see the labels dip below the bars and are no longer approximately in the middle. Perhaps easier to look at:

The extra space afforded by eliminating the gaps between the bars seems to raise the labels a bit, but they are still seemingly aligned with the bottom of the bars rather than the middle.
How can I shift the labels vertically so that they align to the middle?
(Note: I'm using Stata 16, if that makes any difference)
Code:
sysuse nlsw88.dta, clear graph hbar wage, over(married)

You can see that the labels "single" and "married" are approximately aligned to be in the center of the bars.
However, when you have enough variables with a large enough label size, the labels are no longer aligned with the middle, and seem to be shifted down. For example:
Code:
sysuse nlsw88.dta, clear gen arbitrary_cat = "" forvalues i = 1/31 { replace arbitrary_cat = "Arbitrary cat " + "`i'" if mod(_n, 31) == `i' } graph hbar wage, over(arbitrary_cat, sort(wage) label(labsize(0.2cm) labgap(0.05cm)))

Here you can see the labels dip below the bars and are no longer approximately in the middle. Perhaps easier to look at:
Code:
graph hbar wage, over(arbitrary_cat, sort(wage) label(labsize(0.2cm) labgap(0.05cm))) legend(off) asyvars showyvars

The extra space afforded by eliminating the gaps between the bars seems to raise the labels a bit, but they are still seemingly aligned with the bottom of the bars rather than the middle.
How can I shift the labels vertically so that they align to the middle?
(Note: I'm using Stata 16, if that makes any difference)
Comment