Hi,
I am struggling with how to plot a bar graph with x-axis have three categories, for each category it represents the coding for variable g1a_1 (1 No, 2 Neutral, 3 Yes) by group (0 control, 1 intervention), so it will be a total of 6 vertical bars and each of the adjacent two bars represent the "no", "neutral", "yes" responses for control and intervention respectively. Also, on the x-axis, the bar for control and intervention slightly overlaps with each other (bargap(-30)). Y-axis shows the percentage. On top of each bar there is the count for the g1a_1 = 1, g1a_1 = 2, g1a_1 = 3 in control and intervention group separately.
I checked Stata manual, didn't find the information for my case. I also found a user-write command -fbar-, but it doesn't allow -bargap()- option.
Thanks in advance for your thoughts and sharing the code.
Regards,
Mengmeng
I am struggling with how to plot a bar graph with x-axis have three categories, for each category it represents the coding for variable g1a_1 (1 No, 2 Neutral, 3 Yes) by group (0 control, 1 intervention), so it will be a total of 6 vertical bars and each of the adjacent two bars represent the "no", "neutral", "yes" responses for control and intervention respectively. Also, on the x-axis, the bar for control and intervention slightly overlaps with each other (bargap(-30)). Y-axis shows the percentage. On top of each bar there is the count for the g1a_1 = 1, g1a_1 = 2, g1a_1 = 3 in control and intervention group separately.
I checked Stata manual, didn't find the information for my case. I also found a user-write command -fbar-, but it doesn't allow -bargap()- option.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(g1a_1 g1b_1 g1c_1 g1d_1 g1e_1 group) 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 3 3 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 3 1 1 2 2 1 1 1 1 1 1 1 1 1 2 2 2 0 1 1 1 1 3 1 1 1 1 1 1 0 1 1 1 1 1 0 3 2 2 1 1 1 1 2 3 1 1 1 3 1 3 3 2 0 3 3 3 3 3 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 2 1 1 1 1 0 1 2 3 1 2 0 1 1 3 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 1 1 3 1 3 1 1 1 1 1 1 1 1 2 2 2 2 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 2 2 1 2 2 1 3 1 0 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 3 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 0 1 3 3 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 3 3 2 1 1 1 1 1 1 1 1 1 3 3 1 1 1 1 3 3 3 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 3 3 1 3 1 1 3 3 2 1 1 1 1 1 2 1 1 0 1 1 1 1 1 0 2 1 3 2 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 2 2 1 3 3 2 3 2 1 1 1 1 1 1 0 1 1 2 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 2 2 0 1 1 3 1 1 0 1 1 1 1 1 1 1 1 1 3 2 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 3 3 3 1 1 1 1 1 2 3 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 end label values g1a_1 common_label label values g1b_1 common_label label values g1c_1 common_label label values g1d_1 common_label label values g1e_1 common_label label values group group label def group 0 "Control", modify label def group 1 "Intervention", modify
Regards,
Mengmeng
Comment