I would like to plot a stacked bar graph of an "outcome" over hiv status (positive vs. negative) and stratified by sex (male vs. female).
The "outcome" is in fact 3 separate variables ("low", "mid" and "hi") generated from an ordinal yvar with 3 levels ("1" "2" and "3"):
- low = 1 if yvar==1
- mid = 1 if yvar==2
- hi = 1 if yvar==3
I have the below written stacked box plot command:
- graph bar (sum) cvd_low cvd_mid cvd_hi, over(hiv) over(sex) percent legend(label(1 "Low (<10%)") label(2 "Intermediate (10-30%)") label(3 "High (≥30%)") order(1 - "" 2 - "" 3)) stack
The output is also copied below.
Array
The goal is to have, for example, a navy "HIV negative" bar with different levels of outcome (cvd risk) indicated by different opacities (or shades) of the navy. I will very much appreciate any suggestions you may have on how to go about this.
Thanks in advance.
Itai
0 Response to Assigning colors to stacked bar plot with ordinal y-variable.
Post a Comment